cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 11

Need help, powershell will not run from alert action.

I've been working on this for days and tried every option I could think of.  The problem is the alert will not execute a powershell script and I'm not getting any error.  The script works from command line using "runas" as the same user that manages the alerts.  WOuld really appreciate second set of eyes on this... is what I'm doing possible?  There are threads regarding running powershell from monitor/apms here I'm using the alert to run it.

0 Kudos
12 Replies
Level 14

a little twist here but leave off the -noexit and instead of using WCRIPT or CSCRIPT use the Alert ACTION called "Execute an External Program"

and use this in your field PROGRAM TO EXECUTE

C:\windows\system32\windowspowershell\v1.0\powershell.exe -noprofile doit.ps1


BUT alter your .PS1 to this


set-location "C:\Users\networkmgr\orion_scripts\logs"

$F = "out.txt"

get-date | out-file -append $F

exit 0

0 Kudos

My trigger is Ok.. because its triggering as expected.

Changing to Cscript made no difference.

I altered the above changes... still does update log file.  WHen I do a "run-as" this works... its just when I run the Orion exe that it fails.

Removing the "no exit" made not difference.

Running as a external exe action still did not update the out.txt file.

From alert log:

Success - C:\windows\system32\windowspowershell\v1.0\powershell.exe -noprofile C:\Users\Networkmgr\Orion_Scripts\Powershell\doit.ps1

So I know "something" is running in Orion.  Its just not doing what its suppose to do. I'm new to powershell so I'm sure its something I'm over looking. 

My whole reason for using powershell was to handle passwords securely... vbscript calls powershell to unencrypt a password.  This works fine when I don't use solarwinds. 😞

Can someone try running the above?  That would definately point the problem into an environmental issue on my side. 

0 Kudos

i've tested what i proposed to you on my Orion server with an alert and it works great.

it must be an environment issue for you.

0 Kudos

yep. That is what I figured. Thanks much for checking. Time for me to do some reading on powershell env I guess.... 

One thought... my solarwinds alert engine is running as a non-local user... is this the same for you?  

0 Kudos

all my Solarwinds Services are "Local System"

btw - there are new domain policies which can put restrictions even on PowerShell now. this could bite you.

0 Kudos

I tried moving the ps1... still no go. I'll look into the domain policy thingy... thanks!

0 Kudos

I know this is an old thread, but...

I came across this issue as well and my solution was to run powershell with:
powershell -ExecutionPolicy Bypass

Thanks,
Aaron

0 Kudos

I think aaron might be right, I run "Set-ExecutionPolicy Unrestricted", but that is probably a bad thing but it got it to work.

0 Kudos

Thanks for the tips.  The reason I was using PS was to handle passwords.  I ended up finding a tool built in-house (that one of our developers had created for doing the same thing).

Glenn.

0 Kudos

you might try placing your .PS1 file here C:\windows\system32\windowspowershell\v1.0\

instead of where you show it located.

0 Kudos
Level 14

try it using CSCRIPT instead.

0 Kudos
Level 13

Could you post the trigger conditions? The 3rd image above is an action, not a trigger.

0 Kudos