Can someone tell me why the result is 0?
When I run the script on the server with the RMA agent, it replies properly (135). If I run through HM that execute it on a Windows RMA agent, I get 0.
Script:
Code: Select all
$statusUnknown = "ScriptRes:Unknown:"
$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"
$computer = $args[0]
$folder = $args[1]
$size = $args[2]
if (!$computer) {
echo $statusUnknown"Hostname not specified"
exit
} elseif (!$folder) {
echo $statusUnknown"Folder not specified"
exit
} elseif (!$size) {
echo $statusUnknown"Max size not specified"
exit
}
$result = Invoke-Command -Computername $computer -ScriptBlock { "{0:0}" -f ((Get-ChildItem $folder -Recurse | Measure-Object -Property Length -sum).sum / 1MB) }
if ($result -gt $size) {
echo $statusBad$result
} else {
echo $statusOk$result
}