# Set header and the body
$scomHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$scomHeaders.Add('Content-Type','application/json; charset=utf-8')
$bodyraw = "Windows"
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($bodyraw)
$EncodedText =[Convert]::ToBase64String($Bytes)
$jsonbody = $EncodedText | ConvertTo-Json
#Authenticate
$uriBase = 'http://localhost/OperationsManager/authenticate'
$auth = Invoke-RestMethod -Method POST -Uri $uriBase -Headers $scomheaders -body $jsonbody -UseDefaultCredentials -SessionVariable websession
# Add Criteria – Specify the criteria (such as severity, priority, resolution state, etc.)
# Display Columns – Specify the columns which needs to be displayed.
$query = @(@{ "classId"= ""
# Criteria output the critical new alerts
"criteria" = "((Severity = ‘2’) AND (ResolutionState = ‘0’))"
"displayColumns" ="id","severity","monitoringobjectdisplayname","name","age","repeatcount","lastModified"
})
$jsonquery = $query | ConvertTo-Json
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/alert" -Method Post -Body $jsonquery -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$alerts = $Response.Rows
$alerts
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/performanceCounters/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/monitoringObjectProperties/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/healthstate/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$scomHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$scomHeaders.Add('Content-Type','application/json; charset=utf-8')
$bodyraw = "Windows"
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($bodyraw)
$EncodedText =[Convert]::ToBase64String($Bytes)
$jsonbody = $EncodedText | ConvertTo-Json
#Authenticate
$uriBase = 'http://localhost/OperationsManager/authenticate'
$auth = Invoke-RestMethod -Method POST -Uri $uriBase -Headers $scomheaders -body $jsonbody -UseDefaultCredentials -SessionVariable websession
# Add Criteria – Specify the criteria (such as severity, priority, resolution state, etc.)
# Display Columns – Specify the columns which needs to be displayed.
$query = @(@{ "classId"= ""
# Criteria output the critical new alerts
"criteria" = "((Severity = ‘2’) AND (ResolutionState = ‘0’))"
"displayColumns" ="id","severity","monitoringobjectdisplayname","name","age","repeatcount","lastModified"
})
$jsonquery = $query | ConvertTo-Json
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/alert" -Method Post -Body $jsonquery -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$alerts = $Response.Rows
$alerts
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/performanceCounters/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/monitoringObjectProperties/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
$Response = Invoke-RestMethod -Uri "http://localhost/OperationsManager/data/healthstate/{8fafc510-3371-90eb-55ba-403d610238aa}" -Method Get -ContentType "application/json" -UseDefaultCredentials -WebSession $websession
Комментариев нет:
Отправить комментарий