I explain a little which steps we are using:
1. We save the mail and webpage in two variables. The credentials used are mail (for example my mail account)
PowerShell Code
Double-click the code block to select all.$SN_Web = "WEBPAGE...incident.do?WSDL" $cred = Get-Credential
2. We set a web-proxy connection using the Incident Namespace saved in a object
PowerShell Code
Double-click the code block to select all.$SNowWS_Incidents = New-WebServiceProxy -Uri $uri -Namespace Incidents -Credential $credential3. We define a object called $records using the type Incidents.getRecords. Then we can set attributes for filtering the query (here we want active incidents but we can extend with a lot of properties like we fill in Service-Now when we open a incident).
PowerShell Code
Double-click the code block to select all.$records = New-Object Incidents.getRecords $records.active = $true $records.activeSpecified = $true
4. The webproxy object include a function called getRecords which parameter is a record object with attributes defined previously. This function will return all incidents which include the same attributes (in this case all incidents active).
PowerShell Code
Double-click the code block to select all.$INC = $SNowWS_Incidents.getRecords($records)
We will receive all information comming from active incidents (first execution works)
Well until now, looks good and should work but here is when I need your knowledge and experience. If I execute the same code a second time, I receive the following error:
PowerShell Code
Double-click the code block to select all.ERROR: Cannot convert argument "getRecords1", with value: "Incidents.getRecords", for "getRecords" to type "Incidents.getRecords": "Cannot convert the ERROR: "Incidents.getRecords" value of type "Incidents.getRecords" to type "Incidents.getRecords"."
I used PowerShell studio, PowerShell GUI, PowerShell ISE, PowerShell consoled and the error successes in all. We have no idea why we receive this error. Could be coming from PowerShell but maybe you have knowledge about the error or logic problem.
Thanks so much for your support.