PowerShell Scripts with Administrative Privileges
Posted: Wed Aug 22, 2018 4:18 am
Dear Support,
Pl help us in how to execute the windows PowerShell script with Administrative Privileges via NCPA/NRPE agent in Nagios.
As we are not able to configure the windows IIS pool monitoring by using the PowerShell script.
Here we are referring the attached link for reference.
https://exchange.nagios.org/directory/P ... ol/details
Error message while executing the script via NRPE Agent:-
[nagios@jet-nagios-prod ~]$ /usr/local/nagios/libexec/check_nrpe -H 172.28.52.78 -p 5666 -t 60 -c check_ms_iis_application_pool -a '-A JetMBE'
scripts/powershell/check_ms_iis_application_pool.ps1 : The term
'scripts/powershell/check_ms_iis_application_pool.ps1' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ scripts/powershell/check_ms_iis_application_pool.ps1 -A JetMBE; exit
$LastExitCo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (scripts/powersh...cation_pool.p
s1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
/usr/local/nagios/libexec/check_ncpa.py -H 172.28.52.78 -t 'XXXXXX' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1' -a '-A JetMBE'
CRITICAL: Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Where as the same script is working fine on windows server.
PS C:\Users\GANESH.BATWAL\Downloads> .\check_ms_iis_application_pool.ps1 -A JetOBE
OK: Application Pool "JetOBE" with 1 Applications. {CPU: 100 %}{Memory: 643.84 MB} | 'pool_cpu'=100%;;;0;100 'pool_memory'=643.84MB;;;0; 'app_count'=1
PS C:\Users\GANESH.BATWAL\Downloads>
Pl help us in how to execute the windows PowerShell script with Administrative Privileges via NCPA/NRPE agent in Nagios.
As we are not able to configure the windows IIS pool monitoring by using the PowerShell script.
Here we are referring the attached link for reference.
https://exchange.nagios.org/directory/P ... ol/details
Error message while executing the script via NRPE Agent:-
[nagios@jet-nagios-prod ~]$ /usr/local/nagios/libexec/check_nrpe -H 172.28.52.78 -p 5666 -t 60 -c check_ms_iis_application_pool -a '-A JetMBE'
scripts/powershell/check_ms_iis_application_pool.ps1 : The term
'scripts/powershell/check_ms_iis_application_pool.ps1' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ scripts/powershell/check_ms_iis_application_pool.ps1 -A JetMBE; exit
$LastExitCo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (scripts/powersh...cation_pool.p
s1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
/usr/local/nagios/libexec/check_ncpa.py -H 172.28.52.78 -t 'XXXXXX' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1' -a '-A JetMBE'
CRITICAL: Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Where as the same script is working fine on windows server.
PS C:\Users\GANESH.BATWAL\Downloads> .\check_ms_iis_application_pool.ps1 -A JetOBE
OK: Application Pool "JetOBE" with 1 Applications. {CPU: 100 %}{Memory: 643.84 MB} | 'pool_cpu'=100%;;;0;100 'pool_memory'=643.84MB;;;0; 'app_count'=1
PS C:\Users\GANESH.BATWAL\Downloads>