Active IQ Unified Manager Discussions

Pass alarm environment variable to PowerShell

jhorne
7,232 Views

First post here, hope this is the right spot.

I'm trying to pass the environment variables from the OnCommand 5.0 Console Alarm Script to a PowerShell script similar to how it's worked in the past with perl:

https://kb.netapp.com/support/index?page=content&id=3012180

I was wondering if anyone has any experience with this, or is this uncharted territory?

I'd be happy to upload some scripts that I've been working on if there is any interest.

Thanks!

J

10 REPLIES 10

dasimpson1
7,191 Views

Yes I do just recently, see this post I did on it

https://communities.netapp.com/message/70438#

jhorne
7,191 Views

I solved this a while ago, but in a different way. I wasn't able to launch a PowerShell script directly from the alarm. If I put a file with a ps1 extension, it simply ignored it. I'm not sure it there is a problem with my install, or if I'm simply doing it wrong. I was able to create a batch file script, and pass the variable to a PowerShell script inside. Cumbersome, but I got it working. If you're having success launching PowerShell scripts directly from the alarm then that's awesome!

dasimpson1
7,191 Views

Yes I was able to get it to work it took a while but I did not want to go the batch file route some of the keys things were making sure in the path that the executable name to use was present should look something like this (powershell.exe c:\script.ps1) and I think I did self signed for the security in powershell since its running on the on command server. I also dropped the ps1 file on the root of C: and then my script goes to that location before it does anything.

kvadher
7,191 Views

Hello

I've tried what you have documented but I still cannot get the script to execute when I perform an alarm test. I've set the powershell execution policy to Unrestricte with no joy and also placed the script in the root of the c:\.

Any ideas?

wim_van_der_heijden
7,191 Views

Hello,

We are facing the same issue, the alarm triggers the script. If you look in DFM log you will see that the powershell script is executed, but nothing happens. If i run the command which is executed from the alarm via start -> run, then the ps script works. In task manager you can see powershell is exexuted and stopped, but no error is  registered.

Did you find a solution for this?

Wim van der Heijden.

dasimpson1
7,191 Views

I did my script run in my environnement today when an event happens my script will parse the qtree owner and send them a custom email based on the event

dasimpson1
7,191 Views

Sorry guys I know how frustrating  this can be for some reason one of my issues was that before the script ran I needed to send powershell to the script dir....so what I did was in the first part of my script it sets the script run location in the same dir as myscript. I think it was a permission issue or something. Also need to ensure that when the script is excuted its done with the proper permission

wim_van_der_heijden
7,191 Views

Thx for your quick reply.

i can't add the 'Run script as:' option, This is only an option on Unix platforms is the response i get. When i run the command exactly as i do with the Alarm notification script, then the script works. This is the command i use in 'Script': powershell.exe D:\Progs\Powershell\scripts\test.ps1

adaikkap
7,191 Views

Pls use the cli to create or modify the alarm with the script path.

This is a known issue and pls open a case with netapp support center and add it to bug 666431

Regards

adai

Tonny
5,934 Views

Hi,

 

I got alarming working with the following command:

 

dfm alarm create -C Critical -s "powershell -command <scriptname>"

 

I'am now looking for information how toget the alarm variables into my powershell script.

 

If somebody knows how to do this, please share.

 

TIA,

 

Tonny

Public