Powershell Orchestration - Running as Admin

shawn_h
Tera Guru

Hi folks,

I've got a small script which should ideally populate users into the security tab of an active directory group object.

Unfortunately, the script only works locally when it is "Run as Administrator" when I try to run this locally in a Powershell Window.

The first few lines of my script are used to re-open a prompt as admin, which also works locally, but doesn't seem to work when initiating it as a powershell activity from ServiceNow.

The active directory credentials plugged into ServiceNow have admin rights but, alas, the script seems to return the same error as if I would run it without an elevated prompt.

Would anybody be able to help in either running a Powershell command as Admin from ServiceNow, or happen to know another solution that might help in doing the same thing?

 

find_real_file.png

1 ACCEPTED SOLUTION

Hi drewm,

Afraid not. Looks like it isn't possible through ServiceNow from the looks of things.

In the end we've ended up setting up a scheduled task locally to run through and pick up and do the bits that needed elevated rights.

It isn't tidy and doesn't use ServiceNow as a solution, but does what we're after at least.

View solution in original post

7 REPLIES 7

drew25
Tera Contributor

Hey Shawn, were you able to figure out the "Run As Administrator" issue?  We're looking at a different issue, but similar to yours our script runs fine when you run the PowerShell as an administrator on the local machine.  It doesn't work in ServiceNow though.

 

Thanks!

Hi drewm,

Afraid not. Looks like it isn't possible through ServiceNow from the looks of things.

In the end we've ended up setting up a scheduled task locally to run through and pick up and do the bits that needed elevated rights.

It isn't tidy and doesn't use ServiceNow as a solution, but does what we're after at least.

drew25
Tera Contributor

Thanks for the update!  It's unfortunate, but glad it works.