Adventures in Powershell. These posts have been created as a record of the successful powershell commands I have used.
Friday, August 5, 2016
Loops and Call
This is an example of a loop and a call to launch an executable.
This link has examples of other loop types
http://www.winserverhelp.com/2010/04/powershell-tutorial-loops-for-foreach-while-do-while-do-until/2/
# after logon, check for a appv package to be present and then launch it when available.
$IsTextHelpPublishedForMe = $Null
$Count =0
While ($Count -le 10)
{
$IsTextHelpPublishedForMe = Get-AppvClientPackage -packageid 3227A4B4-269A-4970-84B5-302DC1255E40 | select -expand IsPublishedToUser
If ($IsTextHelpPublishedForMe -eq "True")
{
$target = $env:LOCALAPPDATA+"\Microsoft\AppV\Client\Integration\3227A4B4-269A-4970-84B5-302DC1255E40\Root\ReadAndWrite.exe"
& $target
exit
}
Else
{
#integer is seconds to wait
Start-Sleep -s 5
$Count; $Count +=1
}
}