Snow-Shell/servicenow-powershell

How do you add associated CIs to a Change record?

Closed this issue · 3 comments

I can create a change record and ctasks for it but cannot figure out how to add hundreds of Server Cis to affected CI list in the change ticket. Does anyone have examples?
Also the new change record function doesn't return the new change number. I have to query for it after its created.

With the help of ChatGPT I was able to figure this out using the below:
ChatGPT gave me this code:
New-ServiceNowRecord -Table "task_ci" -Fields @{
"task" = $changeSysId
"cmdb_ci" = $serverSysId
}
I was able to change it to this and it worked..
New-ServiceNowRecord -Table "task_ci" -InputData @{
"task" = $changeSysId
"ci_item" = $serverSysId
}

New-ServiceNowChangeRecord has an -InputData parameter you can use directly when creating the change. If you are looking to just pass one item, use the built-in -ConfigurationItem parameter. Also, -PassThru is used to return the details of the new record.

Thanks the -PassThru switch was the only other thing I needed. Appreciate it.