Hallo everyone,
I'm trying to get a Powershell script running to Monitor Veeam Jobs.
The Problem is, that the Veeam SnapIn is not compatible with Powershell Version 4. Nagios defaults to Powershell 4 on the Server though.
Is there any option to make ncpa use a lower Powershell version?
NCPA execute PS1 Script with specific Powershell Version
-
domsch1988
- Posts: 32
- Joined: Tue Aug 15, 2017 1:20 am
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: NCPA execute PS1 Script with specific Powershell Version
have you tried including the full path to Powershell 2/3 to your PS executeable? i don't think this is the most viable solution, but it should work.
for example -
if you were just executing check_veeam.ps1 before, try C:\program files\powershell2\powershell.exe C:\check_veeam.ps1 - may need to use quotes to keep the spaces encapsulated.
for example -
if you were just executing check_veeam.ps1 before, try C:\program files\powershell2\powershell.exe C:\check_veeam.ps1 - may need to use quotes to keep the spaces encapsulated.
Re: NCPA execute PS1 Script with specific Powershell Version
If you're calling the script via NCPA, and you're doing something like -M 'plugins/my_custom_plugin.ps1', then NCPA I believe is going to default to whatever handler Windows has for the .ps1 extension. Be it Powershell 4, MS Paint, or something else entirely (this is how Popen works I think).domsch1988 wrote:Nagios defaults to Powershell 4 on the Server though.
Short of setting up proper environment variables and having different Powershell executables associated with different extensions (maybe .ps3 for Powershell 3?), this is probably the easiest solution:
Essentially, you'd have a wrapper script (a .bat file would be easy) which would be responsible for executing your Powershell script. Then, you'd call that .bat file via NCPA. The .bat file doesn't need to be very complex. It could be as easy as:tacolover101 wrote:have you tried including the full path to Powershell 2/3 to your PS executeable?
Code: Select all
powershell -version 2 .\my_custom_plugin.ps1Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: NCPA execute PS1 Script with specific Powershell Version
Thanks @tacolover101 and @mcapra!
OP, did you have any additional questions or want to add anything?
OP, did you have any additional questions or want to add anything?