Exit code tutorial

Veröffentlicht:  24. Juni 2015
# set your test exit code (0,1,2)
$exitCode = 0

switch ($exitCode) 
{ 
	0 { 
		Write-Host "[OK] Exit Code 0 delivers a green icon "
		exit 0
	} 
	1 { 
		Write-Host "[WARNING] Exit Code 1 delivers a yellow icon"
		exit 1
	} 
	2 { 
		Write-Host "[PROBLEM] Exit Code 2 delivers a red icon"
		exit 2
	} 
	default { 
		Write-Host "[PROBLEM] All other Exit Codes deliver a red icon"
		exit 2
	} 
}