ms.date | ms.topic | keywords | title |
---|---|---|---|
06/12/2017 |
conceptual |
dsc,powershell,configuration,setup |
DSC function to query node information from pull server. |
function QueryNodeInformation
{
Param (
[string] $Uri =
"http://localhost:7070/PSDSCComplianceServer.svc/Status",
[string] $ContentType = "application/json"
)
Write-Host "Querying node information from pull server URI = $Uri" -ForegroundColor Green
Write-Host "Querying node status in content type = $ContentType " -ForegroundColor Green
$response = Invoke-WebRequest -Uri $Uri -Method Get -ContentType $ContentType -UseDefaultCredentials -Headers
@{Accept = $ContentType}
if($response.StatusCode -ne 200)
{
Write-Host "node information was not retrieved." -ForegroundColor Red
}
$jsonResponse = ConvertFrom-Json $response.Content
return $jsonResponse
}
Replace the Uri
parameter with the URI for your pull server. If you want the node information in XML format, set ContentType
to application/xml
.
To retrieve the node information from the $json
parameter, use the following:
$json = QueryNodeInformation –Uri http://localhost:7070/PSDSCComplianceServer.svc/Status
$json.value | Format-Table TargetName, ConfigurationId, ServerChecksum, NodeCompliant, LastComplianceTime, StatusCode