Hi all,
i try to use a powershell script in nagios with this command:
$size = (Get-Item REMOTESERVER\d$\AppData\Exchange\TransportRoles\data\Queue\mail.que).Length
write-host $size
in powershell it works perfectly but when i try to run the script with nrpe on nagios it always exit with 0 because $size is null
any suggestions?
thanks
powershell script remote server
Re: powershell script remote server
Hi,
May I see your nrpe command, please?
Also, please upload your script here as well.
Regards,
Vinh
May I see your nrpe command, please?
Also, please upload your script here as well.
Regards,
Vinh
-
[email protected]
- Posts: 6
- Joined: Wed Sep 28, 2016 5:10 am
Re: powershell script remote server
the script is:
$size = [math]::round((Get-Item \\server\d$\AppData\Exchange\TransportRoles\data\Queue\mail.que).Length /1GB)
$size = (Get-Item \\server\d$\AppData\Exchange\TransportRoles\data\Queue\mail.que).Length
write-host $size
the command is:
cmd /c echo scripts\check_exchange_mail_queue.ps1 $ARG1$ ; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command - 2> $null
thanks
$size = [math]::round((Get-Item \\server\d$\AppData\Exchange\TransportRoles\data\Queue\mail.que).Length /1GB)
$size = (Get-Item \\server\d$\AppData\Exchange\TransportRoles\data\Queue\mail.que).Length
write-host $size
the command is:
cmd /c echo scripts\check_exchange_mail_queue.ps1 $ARG1$ ; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command - 2> $null
thanks
-
optionstechnology
- Posts: 234
- Joined: Thu Nov 17, 2016 11:26 am
Re: powershell script remote server
Any time I see this problem its because nrpe/nagios runs as a local service account and doesn't have access to UNC paths
If your running against a local server try it with the local paths and see if that works
(note I run this exact same check I think using the PS snapin:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
Get-Queue | Select-Object Identity,MessageCount
Might be a better fit as it can execute locally
)
If your running against a local server try it with the local paths and see if that works
(note I run this exact same check I think using the PS snapin:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
Get-Queue | Select-Object Identity,MessageCount
Might be a better fit as it can execute locally
)
-
[email protected]
- Posts: 6
- Joined: Wed Sep 28, 2016 5:10 am
Re: powershell script remote server
on local server it works.
probably you're right doesn't have access to UNC paths
in this case I will run on server locally
thanks for suggestions
probably you're right doesn't have access to UNC paths
in this case I will run on server locally
thanks for suggestions
Re: powershell script remote server
Yes, thank you @optionstechnology .... 