The following PS script shows how to query ServiceNow via SOAP calls, using the WebServiceProxy object. View their Wiki for more examples of service methods
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$username = "XXXXXXXXXX" $password = "YYYYYYYYYY" $instance = "ZZZZZZZZZZ" $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force)) $sn = New-WebServiceProxy -Uri "https://$instance.service-now.com/incident.do?WSDL" –Credential $cred #get autogenerated namespace $type = $sn.GetType().Namespace # Get a single record by sys_id #$get = new-object ($type + '.get') #$get.sys_id="YOUR_SYS_ID_GOES_HERE" #$sn.get($get) #Get records that match values #$getRecords = new-object ($type + '.getRecords') #$getRecords.state=11 #$sn.getRecords($getRecords); |