Need help understanding REST API PowerShell code generated by ServiceNow

gjz
Mega Sage

I have a requirement to retrieve a CSV file from the MID Server and attach it to a Requested Item in a flow.  I haven't found many posts on how to do this, but after a lot of searching, I think I've found code that will work but I don't understand why a few of the lines of code is required.

 

Following Oscar Lopez's post (https://www.servicenow.com/community/itom-articles/automated-data-import-using-mid-server-and-powers...), I've determined the PowerShell script example he gave is the same as what is generated if you use the REST API Explorer.

 

My issue is the first few lines need the MID Server account's UserID and Password.  Not only do I not have that information, we do not want it entered into any code for security reasons.  Can someone explain why these lines are necessary?  The PowerShell script is already going to be run on the MID Server using the MID Server account, why does it need to be added?  If it has to be there, is there an alternative I can use that gets the userid/password from somewhere else?

 

Here are the lines in question:

 

gjz_1-1757018558848.png

 

 

 

1 REPLY 1