Guest User

UpdateAdobeMSP.ps1

a guest
Jan 2nd, 2020
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. $ftp = "ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/"
  2.  
  3. # We have to use .NET to read a directory listing from FTP, it is different than downloading a file.
  4. # Original C# code at https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-list-directory-contents-with-ftp
  5.  
  6. $request = [System.Net.FtpWebRequest]::Create($ftp);
  7. $request.Credentials = [System.Net.NetworkCredential]::new("anonymous", "password");
  8. $request.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectoryDetails;
  9. [System.Net.FtpWebResponse]$response = [System.Net.FtpWebResponse]$request.GetResponse();
  10. [System.IO.Stream]$responseStream = $response.GetResponseStream();
  11. [System.IO.StreamReader]$reader = [System.IO.StreamReader]::new($responseStream);
  12. $DirList = $reader.ReadToEnd()
  13. $reader.Close()
  14. $response.close()
  15.  
  16. # Split into Lines, currently it is one big string.
  17. $DirByLine = $DirList.split("`n")
  18.  
  19. # Get the token containing the folder name.
  20. $folders = @()
  21. foreach ($line in $DirByLine ) {
  22. $endtoken = ($line.split(' '))[-1]
  23. #filter out non version folder names
  24. if ($endtoken -match "[0-9]") {
  25. $folders += $endtoken
  26. }
  27. }
  28.  
  29. # Sort the folders by newest first, and select the first 1, and remove the newline whitespace at the end.
  30. $currentfolder = ($folders | sort -Descending | select -First 1).trim()
  31.  
  32. # PowerShell Wrapper for MDT, Standalone and Chocolatey Installation - (C)2015 xenappblog.com
  33. # Example 1: Start-Process "XenDesktopServerSetup.exe" -ArgumentList $unattendedArgs -Wait -Passthru
  34. # Example 2 Powershell: Start-Process powershell.exe -ExecutionPolicy bypass -file $Destination
  35. # Example 3 EXE (Always use ' '):
  36. # $UnattendedArgs='/qn'
  37. # (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode
  38. # Example 4 MSI (Always use " "):
  39. # $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp"
  40. # (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode
  41.  
  42. Clear-Host
  43. Write-Verbose "Setting Arguments" -Verbose
  44. $StartDTM = (Get-Date)
  45.  
  46. $Vendor = "Adobe"
  47. $Product = "Reader DC"
  48. $PackageName = "AcroRdrDCUpd"
  49. $Version = "$currentfolder"
  50. $InstallerType = "msp"
  51. $Source = "$PackageName" + "." + "$InstallerType"
  52. $LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log"
  53. $LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log"
  54. $Destination = "${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType"
  55. $UnattendedArgs = '/sAll /msi /norestart /quiet ALLUSERS=1 EULA_ACCEPT=YES'
  56. $ProgressPreference = 'SilentlyContinue'
  57.  
  58. Start-Transcript $LogPS | Out-Null
  59.  
  60. Write-Verbose "Checking Internet Connection" -Verbose
  61.  
  62. If (!(Test-Connection -ComputerName www.google.com -Count 1 -quiet)) {
  63. Write-Verbose "Internet Connection is Down" -Verbose
  64. }
  65. Else {
  66. Write-Verbose "Internet Connection is Up" -Verbose
  67. }
  68.  
  69. Write-Verbose "Writing Version Number to File" -Verbose
  70. if (!$Version) {
  71. $Version = Get-Content -Path ".\Version.txt"
  72. }
  73. Else {
  74. $Version | Out-File -FilePath ".\Version.txt" -Force
  75. }
  76.  
  77. if( -Not (Test-Path -Path $Version ) )
  78. {
  79. New-Item -ItemType directory -Path $Version | Out-Null
  80. $Version | Out-File -FilePath ".\Version.txt" -Force
  81. }
  82.  
  83. CD $Version
  84.  
  85. If (!(Test-Path -Path $Source)) {
  86. Write-Verbose "Downloading $Vendor $Product $Version" -Verbose
  87. $MSPDownload = "$($ftp)$($currentfolder)`/AcroRdrDCUpd$($currentfolder).msp"
  88. $filename = ($MSPDownload.split("/"))[-1]
  89. wget -uri $MSPDownload -outfile $Source
  90. }
  91. Else {
  92. Write-Verbose "File Exists. Skipping Download." -Verbose
  93. }
  94.  
  95. Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose
  96. Start-Process -FilePath "$env:SystemRoot\System32\msiexec.exe" -ArgumentList "/update $Source /quiet /norestart ALLUSERS=1 EULA_ACCEPT=YES'" -Wait
  97.  
  98. Write-Verbose "Customization" -Verbose
  99. Unregister-ScheduledTask -TaskName "Adobe Acrobat Update Task" -Confirm:$false
  100. Set-Service AdobeARMservice -StartupType Disabled
  101.  
  102. Write-Verbose "Stop logging" -Verbose
  103. $EndDTM = (Get-Date)
  104. Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
  105. Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
  106. Stop-Transcript | Out-Null
Add Comment
Please, Sign In to add comment