Hi Powershell Experts,
Currently we are developing a script that allows to open/update incidents in service-now automatically, allowing to monitoring incidents directly with the user, crossing our ticket platform. In the past, I did we could open tickets from the script. I explain a little which steps we are using:
- We save the mail and webpage in two variables. The credentials used are mail (for example my mail account)
$SN_Mail = “firstname.lastname@example.org”
$SN_Web = “https://hexagontechnology.service-now.com/incident.do?WSDL”
$cred = Get-Credential
- We set a web-proxy connection using the Incident Namespace saved in a object
$SNowWS_Incidents = New-WebServiceProxy -Uri $uri -Namespace Incidents -Credential $credential
- 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).
$records = New-Object Incidents.getRecords
$records.active = $true
$records.activeSpecified = $true
- 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).
$INC = $SNowWS_Incidents.getRecords($records)
first execution: we receive the correct information.
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:
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.