Server Management - Systems Insight Manager
1753613 Members
5880 Online
108797 Solutions
New Discussion юеВ

HPSIM running a powershell script for an event

 
David Borojevic
Trusted Contributor

HPSIM running a powershell script for an event

Hi there,

We have tried to get an HPSIM event to execute a powershell script. It appears to open powershell but doesn't run the script.

Is there a trick to get this to work?

Thanks
10 REPLIES 10
Rob Buxton
Honored Contributor

Re: HPSIM running a powershell script for an event

Which version of HPSIM?

I'm not familiar with powershell, how do you pass the script to run?

To run our perl commands it is just a matter of specifying the location of the perl image and file to run; e.g.
c:\perl\perl.exe d:\perl_script\myfile.pl
in the command to launch part of the costom command set up.
Rob Buxton
Honored Contributor

Re: HPSIM running a powershell script for an event

After a brief look at the MS docs, and with no real knowledge of the product have you just tried using the full path to the powershell script as the command?

David Borojevic
Trusted Contributor

Re: HPSIM running a powershell script for an event

Full path is in there. And also full path to powershell script as well doesn't make a difference.

It seems to launch powershell but fails to run the powershell script. We have to kill the powershell process via task manager so it is definitely getting that far. The same launch technique outside of HPSIM works.

Cheers
Rob Buxton
Honored Contributor

Re: HPSIM running a powershell script for an event

What does the Command on the Custom Command actually look like?
Can you provide an example?
NJK-Work
Honored Contributor

Re: HPSIM running a powershell script for an event

Hi David,

I do know for powershell, you do have to enable security within them to allow scripts to be run.

Out of the box, PowerShell is is just a interactive shell. In order to allow scripts to be run, you have to run a command within the powershell to enable a certain level of script functionality. It then remembers that setting for future scripts.

Have you done this?
Nelson
NJK-Work
Honored Contributor

Re: HPSIM running a powershell script for an event

Changing the Windows PowerShell Script Execution Policy
The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:

├в ┬в Restricted ├в No scripts can be run. Windows PowerShell can be used only in interactive mode.

├в ┬в AllSigned ├в Only scripts signed by a trusted publisher can be run.

├в ┬в RemoteSigned ├в Downloaded scripts must be signed by a trusted publisher before they can be run.

├в ┬в Unrestricted ├в No restrictions; all Windows PowerShell scripts can be run.


To assign a particular policy simply call Set-ExecutionPolicy followed by the appropriate policy name. For example, this command sets the execution policy to RemoteSigned:

Set-ExecutionPolicy RemoteSigned

David Borojevic
Trusted Contributor

Re: HPSIM running a powershell script for an event

Thanks

We have tried with powershell set to unrestricted to no avail. Maybe we will try and sign a script.

Cheers
Rob Buxton
Honored Contributor

Re: HPSIM running a powershell script for an event

Judging by this thread I think I'll stick with perl!

From a cmd line, if you just enter the name of the PS script does it run?
If it does then the launch line in HPSIM would be just the name of the PS script.

I guess another test maybe to nestle the PS in a batch file and see what happens there.
Marco Shaw_1
Respected Contributor

Re: HPSIM running a powershell script for an event

How are you calling the script? Are you trying to call the .ps1 file directly? Due to PowerShell security features, this will not work out of the box. I find it easiest to wrap the PowerShell script in a VBScript script.

See here for more info:
http://blog.sapien.com/current/2006/12/25/more-fun-with-scheduled-powershell.html