System : Windows 2012ServerR2 6.3.9600
where the servers are located [In DMZ or not] : Servers are in the DMZ and not domain members.
ncpac version : 2.1.1
Version of Exchange : Exchange 2013
one of my team is attempting to load a Powershell PSSnapin for exchange on these systems so I can interrogate the message queue for monitoring. When using ncpa to load the service monitor Exchange Queue Length, the script fails.
The error is related to loading the Exchange powershell snapin loaded to execute the powershell script that returns queue length. The script get-QueueLength.ps1 runs on the server however fails to load when executed from Nagios
[nagios@monrck-vccn003 ~]$ /usr/local/nagios/libexec/check_ncpa.py -H server -t 'token' -P 5693 -M 'plugins/Nagios_Get-QueueLength.ps1'
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version
4.
At C:\Program Files (x86)\Nagios\NCPA\plugins\Nagios_Get-QueueLength.ps1:8
char:1
+ Add-PSSnapin "Microsoft.Exchange.Management.PowerShell.SnapIn"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Excha...werShell.Sna
pIn:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
dPSSnapinCommand
We Also Tried the some troubleshooting steps by following a post #53056 and we still face with the below errors
.ps1 = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\Microsoft\Exchange Server\V15\bin\Microsoft.Exchange.PowerShell.Configuration.dll"
Still getting this:
$ /usr/local/nagios/libexec/check_ncpa.py -H server -t 'token' -P 5693 -M 'plugins/Nagios_Get-QueueLength.ps1'
Processing -File '"Microsoft.Exchange.Management.PowerShell.SnapIn"' failed: Illegal characters in path. Specify a valid path for the -File parameter.
Or when I use single quotes around the full snappin name like this 'Microsoft.Exchange.Management.PowerShell.SnapIn':
$ /usr/local/nagios/libexec/check_ncpa.py -H server -t 'token' -P 5693 -M 'plugins/Nagios_Get-QueueLength.ps1'
Processing -File ''Microsoft.Exchange.Management.PowerShell.SnapIn'' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.
Check NCPA , PSSnappin error for Exchange 2013
Re: Check NCPA , PSSnappin error for Exchange 2013
It is possible that you need to modify the ncpa.cfg by using the 64-bit powershell. Comment out the "default .ps1" line (or whatever you currently have), e.g.:
and uncomment the following line:
Save, exit, and restart NCPA services on the Windows machine. Try your check again. Did this help?
Code: Select all
# .ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_argsCode: Select all
.ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_argsBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check NCPA , PSSnappin error for Exchange 2013
we tried that and we still get issue. Added our ncpa Config screenshot.
We do have this work on other exchange servers, only thing that seems different to this server is that its not a domain members.
we tried bunch of combination
.ps1 = %SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
The script works fine only when executed locally from powershell in the machine,
The same script when ran form powershell(x86) it fails with the same error
We did restart NCPA listener service every time we tested
We do have this work on other exchange servers, only thing that seems different to this server is that its not a domain members.
we tried bunch of combination
.ps1 = %SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
The script works fine only when executed locally from powershell in the machine,
The same script when ran form powershell(x86) it fails with the same error
We did restart NCPA listener service every time we tested
You do not have the required permissions to view the files attached to this post.
Re: Check NCPA , PSSnappin error for Exchange 2013
Previously, you showed us a few different errors. Which of these are you seeing now? Can you show us the ncpa_listener.log?The same script when ran form powershell(x86) it fails with the same error
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check NCPA , PSSnappin error for Exchange 2013
Attached is the ncpa_listener log file
You do not have the required permissions to view the files attached to this post.
Re: Check NCPA , PSSnappin error for Exchange 2013
I spoke to our developers, and they believe it is possible that you are not using the proper powershell version. You can try using:
to see if this is going to fix the issue.
We don't have access to your system, and cannot test this in-house, so it is hard to troubleshoot the issue. According to Microsoft, Add-PSSnapin adds the snap-in only to the current session. Have you tried adding the snap-in to your Windows PowerShell profile?
https://docs.microsoft.com/en-us/powers ... rshell-5.1
Code: Select all
.ps1 = C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_argsWe don't have access to your system, and cannot test this in-house, so it is hard to troubleshoot the issue. According to Microsoft, Add-PSSnapin adds the snap-in only to the current session. Have you tried adding the snap-in to your Windows PowerShell profile?
https://docs.microsoft.com/en-us/powers ... rshell-5.1
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Check NCPA , PSSnappin error for Exchange 2013
Thank you, Adding the PSSnappin to $profile.AllUsersAllHosts fixed the issue.
Re: Check NCPA , PSSnappin error for Exchange 2013
Glad to hear this worked!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!