Advertisement
mesmariusz

ps1 script to check if an app installed

Apr 24th, 2022
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. param(
  2. [string]$AppToCheckIfInstalled
  3. )
  4.  
  5. if ($AppToCheckIfInstalled) {
  6.  
  7. Write-Host Checking if the application $AppToCheckIfInstalled has already been installed...
  8.  
  9. # $cmdOutput = $AppToCheckIfInstalled 2>&1
  10. $rawOutput = (cmd /c $AppToCheckIfInstalled 2`>`&1)
  11.  
  12. if ($rawOutput -like "*'$AppToCheckIfInstalled' is not recognized*") {
  13. Write-Host "$AppToCheckIfInstalled not installed yet"
  14. }
  15. else {
  16. Write-Host "$AppToCheckIfInstalled already installed"
  17. }
  18. }
  19. else {
  20. Write-Host "Missing application name, exiting..."
  21. }
  22.  
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement