Snippet of the script that I am executing :
$reader = $managementgroupobj.GetMonitoringPerformanceDataReader()
while ($reader.Read()) // << Error in this line.
{
$perfData = $reader.GetMonitoringPerformanceData()
$valueReader = $perfData.GetValueReader($starttime,$endtime)
while ($valueReader.Read())
{
$perfValue = $valueReader.GetMonitoringPerformanceDataValue()
}
}
Here, $managementgroupobj
is an instance of class ManagementGroup
.
The difference of $starttime
and $endtime
veries from 15 minutes to 1 hour depending on the last execution of the same script.
The snippet collects the performance the data successfully for long time. but then, out of nowhere it throws following error:
"The requested reader was not valid. The reader either does not exist or has expired"
[ log_level=WARN pid=2716 ] Execute command 'get-scomallperfdata' failed. The requested reader was not valid. The reader either does not exist or has expired.
at GetSCOMPerformanceData, E:\perf\scom_command_loader.ps1: line 628
at run, E:\perf\scom_command_loader.ps1: line 591
at <ScriptBlock>, E:\perf\scom_command_loader.ps1: line 815
at <ScriptBlock>, <No file>: line 1
at <ScriptBlock>, <No file>: line 46
at Microsoft.EnterpriseManagement.Common.Internal.ServiceProxy.HandleFault(String methodName, Message message)
at Microsoft.EnterpriseManagement.Common.Internal.EntityObjectsServiceProxy.GetObjectsFromReader(Guid readerId, Int32 count)
at Microsoft.EnterpriseManagement.Common.DataReader.Read()
at CallSite.Target(Closure , CallSite , Object )
- What is the cause of the mentioned error.?
- It would be great if I get to know the mechanism of the PerformanceDataReader.
Note:
- The amount of data it fetched before getting error was 100k+. and it took almost an hour to fetch that data.
- I think the possible issue was with amount of data it has to fetch, It might be a kind of TimoutException.
- It would be great if I get atleast some knowledge of both questioned mention above.
Thanks.