Page 1 of 1

check_ncpa & powershell

Posted: Mon Mar 18, 2019 9:12 am
by melidonis
Hi.
I'm trying to run a powershell script with check_ncpa and I want to add a snapin. But when I use this command
"Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010"

I get this error :
"Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2."

Any ideas?

Thank you.

Re: check_ncpa & powershell

Posted: Mon Mar 18, 2019 4:54 pm
by ssax
That is almost acting like you're trying to run that script on a server that doesn't have Exchange installed on it (so no snap-in available), if you run the powershell script manually on the remote server, does it work?

Edit: Another question, is this 32-bit or 64-bit Exchange? Is this a 32-bit or 64-bit OS?

Re: check_ncpa & powershell

Posted: Tue Mar 19, 2019 1:34 am
by melidonis
Exchange is installed on the server and both are 64bit versions. If I run the script on the server it runs correctly.

Re: check_ncpa & powershell

Posted: Tue Mar 19, 2019 5:15 am
by melidonis
I created a script with a single line

Code: Select all

[IntPtr]::Size
and I called it from nagios. The result I got was "4". That means that ncpa is calling the x86 version of powershell and the 64bit version. How can I change that?

Thank you.

Re: check_ncpa & powershell

Posted: Tue Mar 19, 2019 2:08 pm
by ssax
Ok, that's likely why then, please try changing your ncpa.cfg .ps1 definition from:

Code: Select all

.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
To the 64 bit version:

Code: Select all

.ps1 = %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File $plugin_name $plugin_args
Then restart the ncpa_listener service and see if it works properly now.

Re: check_ncpa & powershell

Posted: Tue Mar 19, 2019 2:12 pm
by ssax
Or you might be able to rename your powershell plugin to pluginname.ps64 and add the line below as an alternate means of having both:

Code: Select all

.ps64 = %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File $plugin_name $plugin_args