Advertisement
Daveid

Deploy Bluebook

Mar 21st, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.62 KB | Software | 0 0
  1. #Variables
  2. $AppName = 'Bluebook'
  3. $AppVersion = '0.9.257'
  4. $AppFileName = $AppName + '_' + $AppVersion + '.exe'
  5. $RemoteAppPath = "\\BCS.local\SYSVOL\BCS.Local\Apps\$AppName\$AppFileName"
  6. $SetupAppPath = 'C:\TempPath\' + $AppName
  7. $InstallPath = "$env:LOCALAPPDATA\Programs\bluebook\Bluebook.exe"
  8. $ProgressPreference = 'SilentlyContinue'
  9.  
  10. #Create Setup Path
  11. if (!(Test-Path $SetupAppPath )) { New-Item -Path $SetupAppPath -ItemType Directory -Force }
  12.  
  13. #Start Logging
  14. Start-Transcript -Path "$SetupAppPath\Deploy_$AppName.log" -Force
  15.  
  16. #Check If Installed
  17. if ((Test-Path "$InstallPath")) {
  18.     Write-Host "$AppName is already installed. Aborting..."
  19.     Stop-Transcript
  20.     Exit
  21. } else {
  22.     #Check Setup File
  23.     if ((Test-Path "$SetupAppPath\$AppFileName")) {
  24.         Write-Host "$AppName installer already exists. Proceeding with install..."
  25.     } else {
  26.         Write-Host "$AppName installer is missing. Downloading..."
  27.         Copy-Item "$RemoteAppPath" -Destination "$SetupAppPath\$AppFileName" -Force -Confirm:$false
  28.         if (!(Test-Path "$SetupAppPath\$AppFileName")) {
  29.             Write-Host "$AppName installer failed to download! Review logs to troubleshoot."
  30.             Stop-Transcript
  31.             Exit
  32.         } else {
  33.             Write-Host "$AppName installer successfully download!"
  34.         }
  35.     }
  36.     #Install App
  37.     Write-Host "Installing $AppName" -ForegroundColor Yellow
  38.     Start-Process -FilePath "$SetupAppPath\$AppFileName" -ArgumentList "/S" -Wait
  39.     if ((Test-Path "$InstallPath")) {
  40.         Write-Host "$AppName was successfully installed!"
  41.         Stop-Transcript
  42.         Exit
  43.     } else {
  44.         Write-Host "$AppName failed to install! Review logs to troubleshoot."
  45.         Stop-Transcript
  46.         Exit
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement