I want to pass two arguements with a powershell-script.
This is the regular check
test = cmd /c echo scripts\test.ps1 ; exit($lastexitcode) | powershell.exe -command -
This is the idea that i want. To set warning and critical.
test = cmd /c echo scripts\test.ps1 -w 10 -c 50 ; exit($lastexitcode) | powershell.exe -command -
If warning is set to over 10 then it will return exit 1
If critical is set over 50 then it will return exit 2
Not sure howto do this in my script.
Here is how it looks now.
$condition = (Get-Service | Where-Object Status -eq "Running").Count
if ($argument warn) {
Write-Output "Warning:" $condition
exit 1
}
ElseIf ($argument critical) {
Write-Output "Critical:" $condition
exit 2
}
Although I'm not quite sure if this is what you mean, but you can start the script with a param() block so it accepts arguments like