I would like to count how many times that I check the result. This the part of the process looks like:
function GetValueResult
{
...Some Process...
$Result = $ReturnCode
}
GetValueResult
if ($Result -eq 0)
{
Write-Host "The process Pass"
Restart-Computer
}
elseif ($Result -eq 1)
{
Write-Host "Try again"
GetValueResult
#This part I need to know how many times that I call this function "GetValueResult"
}
Anyone can help me how to count how many times that I call the function "GetValueResult"? If it already 3 times, than I need to do further action. Thanks for help.
counterneeds to survive aRestart-Computerin which case I would use the registry for keeping track of yourcounter. In which case it is also good to know if it conserns the SYSTEM account or not.