The quest to make all my install wrappers evergreen continues and in this post I’m going to share the ever popular screen capture tool GreenShot.
Check my Github repo for all available scripts.
Be aware that there’s a GreenShot.ini located in %AppData% which you would want to edit to disable application update ->Â UpdateCheckInterval=0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# https://githubusercontent.com/BronsonMagnan/SoftwareUpdate/master/Greenshot.ps1 function Get-GreenShotURL { [cmdletbinding()] [outputtype([string])] $GreenshotURL="http://getgreenshot.org/downloads/" $raw = (wget -Uri $GreenshotURL).content #we are looking for the github download $pattern = "https:\/\/github\.com.+\.exe" #split into lines, then split into tags, #$%^ is arbitrary $multiline = $raw.split("`n").trim().replace("<","#$%^<").split("#$%^") #find the html tag containing the github url $urlline = ($multiline | select-string -Pattern $pattern).tostring().trim() #url line now looks like this #<a href="https://github.com/greenshot/greenshot/releases/download/Greenshot-RELEASE-1.2.10.6/Greenshot-INSTALLER-1.2.10.6-RELEASE.exe"> #strip out the html tags $greenshotURL = $urlline.replace('<a href="','').replace('">','') Write-Output $GreenshotURL } function Get-GreenShotVersion { [cmdletbinding()] [outputtype([Version])] $GreenshotURL = Get-GreenShotURL $versionPattern = "\d+\.\d+\.\d+\.\d+" #get the URL and split it on the forward slash, then look for the version pattern $productTitle=($GreenshotURL.split("/") | select-string -Pattern $versionPattern | Select-Object -First 1).tostring().trim() #there will be two because they put the version in the EXE and also in the path as a subfolder. $GreenshotVersion = [VERSION]::new(($productTitle.split('-') | select-string -Pattern $versionPattern | Select-Object -First 1).tostring().trim()) write-output $GreenshotVersion } #usage Get-GreenShotURL Get-GreenShotVersion # PowerShell Wrapper for MDT, Standalone and Chocolatey Installation - (C)2015 xenappblog.com # Example 1: Start-Process "XenDesktopServerSetup.exe" -ArgumentList $unattendedArgs -Wait -Passthru # Example 2 Powershell: Start-Process powershell.exe -ExecutionPolicy bypass -file $Destination # Example 3 EXE (Always use ' '): # $UnattendedArgs='/qn' # (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode # Example 4 MSI (Always use " "): # $UnattendedArgs = "/i $PackageName.$InstallerType ALLUSERS=1 /qn /liewa $LogApp" # (Start-Process msiexec.exe -ArgumentList $UnattendedArgs -Wait -Passthru).ExitCode Clear-Host Write-Verbose "Setting Arguments" -Verbose $StartDTM = (Get-Date) $Vendor = "Misc" $Product = "GreenShot" $PackageName = "GreenShot" $Version = "$(Get-GreenShotVersion)" $InstallerType = "exe" $Source = "$PackageName" + "." + "$InstallerType" $LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log" $LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log" $Destination = "${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" $UnattendedArgs = '/VERYSILENT /SUPPRESSMESSAGEBOXES /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /NORESTART' $ProgressPreference = 'SilentlyContinue' $URL = "$(Get-GreenShotURL)" Start-Transcript $LogPS if ( -Not (Test-Path -Path $Version ) ) { New-Item -ItemType directory -Path $Version } CD $Version Write-Verbose "Downloading $Vendor $Product $Version" -Verbose If (!(Test-Path -Path $Source)) { [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" Invoke-WebRequest -Uri $url -OutFile $Source } Else { Write-Verbose "File exists. Skipping Download." -Verbose } Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose if (Get-Process 'Greenshot' -ea SilentlyContinue) {Stop-Process -processname Greenshot} .\GreenShot.exe /VERYSILENT Start-Sleep -s 10 get-process iexplore | stop-process Write-Verbose "Customization" -Verbose Write-Verbose "Stop logging" -Verbose $EndDTM = (Get-Date) Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose Stop-Transcript |
I prefer the ZIP-way [1], then you dont have to deal with the annoying iexplore.exe.
[1] http://ivan.dretvic.com/2014/01/deploying-greenshot-screen-capture-software-with-sccm-2012/
Agree Markus, but in terms of my deployment which are 100% automated it really doesn’t bother me. For others reading this, the ZIP way is the only way around.