This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Still kinda new to PoSH scripting so if I made a stupid mistake lemme know. I've been piecing and building this all afternoon to test if App installed, if not installed run installer but I didn't want it stuck in an eternal look so I figured I would have it try install once, and also catch if already installed remove/re-install. But this block is stuck where the arrow points. $App_Test_Count is set to 1 after running code every time and it won't increment, Why?
Function App_Test(){
If(Test-Path $App_Loc){
$Global:Inst_Ver_App = (Get-Command $App_Loc).FileVersionInfo.FileVersion
[Bool]$Global:App_Test = $True
# Insert Code here for Logging
} ElseIf (!(Test-Path $App_Loc)){
$App_Test_Count = 0
While($App_Test_Count -le 2){
IF($App_Test_Count = 1){
IF($App_Test_Count -eq 1){
Write-Host "App will be Removed and Re-Installed Now"
# Insert Code here to Un-Install App
# Insert Code here to Install App
# Insert Code here for Logging
$App_Test_Count
} ElseIf($App_Test_Count = 0){
} ElseIf($App_Test_Count -eq 0){
Write-Host "App will be Installed Now"
# Insert Code here to Install App
# Insert Code here for Logging
$App_Test_Count
}
}
}
}
Edited to show corrected and working script.
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...