Make Servicenow Soap Calls With Powershell

under Programming PowerShell ServiceNow

 

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

$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);