How to run PowerShell script from ServiceNow?

Hima Pallela1
Tera Guru

How to run PowerShell script from ServiceNow?

 

Hi,

I have a PowerShell script(.ps1) which imports the user ID's from the active directory and creates a csv file in Mid Server folder. Today I am running the script manually using the command prompt(PS>.\filename.ps1). This script file is in E:\Abc\ folder.

How can I run this command or directly execute the PowerShell script from ServiceNow so that csv created with user ID's in Mid Server?

Is anyone implemented similar solutions? Can you please advise?

 

#PowerShell #Automation

1 ACCEPTED SOLUTION

Zach Koch
Giga Sage
Giga Sage

This link has some explanations that may help you

https://community.servicenow.com/community?id=community_article&sys_id=0cf18778dbb348d4f7fca851ca961...

If this solved your issue, please mark this correct and helpful, thank you!

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

View solution in original post

3 REPLIES 3

Zach Koch
Giga Sage
Giga Sage

This link has some explanations that may help you

https://community.servicenow.com/community?id=community_article&sys_id=0cf18778dbb348d4f7fca851ca961...

If this solved your issue, please mark this correct and helpful, thank you!

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!

Rahul Priyadars
Giga Sage
Giga Sage

I think i have done this in past for a .BAT file , Very Old Days.

You can use Windows Task Scheduler to Schedule your script to RUN. TRY this way.

Tom Rausch
Tera Guru

Hello, @Hima Pallela ,

 

We create our own PowerShell Discovery Probes and Sensors by copying factory Discovery Probes and Sensors. You can likely do the same for your own needs.

Example

Here are two examples of Trigger Probes that launch our own PowerShell Discovery Probes.

find_real_file.png

 

One of our Trigger Probes runs an ad-hoc PowerShell script and places the results in the Comments field of the associated server device.

Here is the Discovery Probe.

find_real_file.png

Here is the ad-hoc PowerShell script.

find_real_file.png

 

Here is the Discovery Sensor.

find_real_file.png

Does this help you?

Regards,

@Tom Rausch