Home Directory

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory

carlschulz

Reviews(1)
bycarlschulz, June 5, 2014
This useful script gives good control on the state of your AD accounts. I wanted to show a Warning at 1 and Critical at 2 or more errors, ran into a problem with the script.

Solution:

returning 0 or one element in an array results in a different return variable not supporting the .Count property

change the invoke-expression line to
$result=@(invoke-expression -Command "$command" -OutBuffer 1000)

to correctly process the return value of the script in the NSClient++ call of the powershell script and pass it on we need to use exit $lastexitcode otherwise we are passing on the success of powershell not the return value of the script itself.

So the NSClient++ ini file needs to contain lines like this:

check_ps_lotp_check_ad_account_disabled=cmd /c echo scripts\lotp_check_ad_accounts.ps1 AccountDisabled "cn=AAA,dc=BBB,dc=com" Subtree 0 1; exit $lastexitcode | powershell.exe -noprofile -executionpolicy bypass -command -

cn= evaluation is not evaluated by the script, some changes are needed there too or just hardcode the SearchBase variable

That's it!