Skip to content

Instantly share code, notes, and snippets.

@gigi81
Created May 11, 2016 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigi81/be053f9975bc867e42fca873ee811a28 to your computer and use it in GitHub Desktop.
Save gigi81/be053f9975bc867e42fca873ee811a28 to your computer and use it in GitHub Desktop.
$PullServer = "localhost:8050"
$ConfigurationId = "45268a6b-9f2d-49eb-a328-79920b389e7a"
#region Generate report
function Get-DscStatusReport
{
param(
$ServiceURL,
$ConfigurationId = "$((glcm).ConfigurationId)"
)
# web requests settings
$requestUri = "$ServiceURL/Node(ConfigurationId='$ConfigurationId')/StatusReports"
$headers = @{
Accept = "application/json";
ProtocolVersion = "2.0"
}
$contentType = "application/json;odata=minimalmetadata;streaming=true;charset=utf-8"
# fire web request
$sw = [Diagnostics.Stopwatch]::StartNew()
$request = Invoke-WebRequest -Uri $requestUri -ContentType $contentType -UseBasicParsing -Headers $headers
$sw.Stop()
Write-Verbose "StatusReports web request took $($sw.Elapsed)"
# convert json response data to an object
$object = ConvertFrom-Json $request.content
$status = $object.value
Write-Verbose "Found $($status.Count) reports"
# fix StartTime and EndTime type
foreach($item in $status)
{
$item.StartTime = [datetime]$item.StartTime
$item.EndTime = [datetime]$item.EndTime
}
return $status
}
Get-DscStatusReport "http://$($PullServer)/PSDSCPullServer.svc" $ConfigurationId | Sort-Object -Property StartTime -Descending | Select-Object -First 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment