forked from haavarstein/Evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09eeb68
commit c6a5165
Showing
10 changed files
with
298 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Applications" : { | ||
"AdobeAcrobatReaderDC" : { | ||
"Uri": "https://armmf.adobe.com/arm-manifests/mac/AcrobatDC/reader/current_version.txt", | ||
"ContentType" : "text/plain; charset=utf-8", | ||
"Languages" : [ | ||
"en_US", "de_DE", "es_ES", "fr_FR", "ja_JP" | ||
] | ||
} | ||
}, | ||
"Preferences" : { | ||
"ErrorAction" : "SilentlyContinue" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Function ConvertTo-Hashtable { | ||
<# | ||
.SYNOPSIS | ||
Converts a PSCustomObject into a hashtable for Windows PowerShell | ||
.NOTES | ||
Author: Adam Bertram | ||
Link: https://4sysops.com/archives/convert-json-to-a-powershell-hash-table | ||
#> | ||
[OutputType([System.Collections.Hashtable])] | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline)] | ||
$InputObject | ||
) | ||
|
||
Process { | ||
## Return null if the input is null. This can happen when calling the function | ||
## recursively and a property is null | ||
If ($Null -eq $InputObject) { | ||
Return $Null | ||
} | ||
|
||
## Check if the input is an array or collection. If so, we also need to convert | ||
## those types into hash tables as well. This function will convert all child | ||
## objects into hash tables (if applicable) | ||
If ($InputObject -is [System.Collections.IEnumerable] -and $InputObject -isnot [string]) { | ||
$collection = @( | ||
ForEach ($object in $InputObject) { | ||
ConvertTo-Hashtable -InputObject $object | ||
} | ||
) | ||
|
||
## Return the array but don't enumerate it because the object may be pretty complex | ||
Write-Output -NoEnumerate -InputObject $collection | ||
} | ||
ElseIf ($InputObject -is [psobject]) { | ||
## If the object has properties that need enumeration | ||
## Convert it to its own hash table and return it | ||
$hash = @{ } | ||
ForEach ($property in $InputObject.PSObject.Properties) { | ||
$hash[$property.Name] = ConvertTo-Hashtable -InputObject $property.Value | ||
} | ||
$hash | ||
} | ||
Else { | ||
## If the object isn't an array, collection, or other object, it's already a hash table | ||
## So just return it. | ||
$InputObject | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Function Get-ModuleResource { | ||
<# | ||
.SYNOPSIS | ||
Reads the module strings from the JSON file and returns a hashtable. | ||
#> | ||
[OutputType([System.Management.Automation.PSObject])] | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $False, Position = 0)] | ||
[ValidateNotNull()] | ||
[ValidateScript( { If (Test-Path -Path $_ -PathType 'Leaf') { $True } Else { Throw "Cannot find file $_" } })] | ||
[System.String] $Path = (Join-Path -Path $MyInvocation.MyCommand.Module.ModuleBase -ChildPath "Get.Software.json") | ||
) | ||
|
||
try { | ||
Write-Verbose -Message "$($MyInvocation.MyCommand): read module resource strings from [$Path]" | ||
$content = Get-Content -Path $Path -Raw -ErrorAction SilentlyContinue | ||
} | ||
catch [System.Exception] { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): failed to read from: $Path." | ||
Throw $_.Exception.Message | ||
} | ||
|
||
try { | ||
If (Test-PSCore) { | ||
$script:resourceStringsTable = $content | ConvertFrom-Json -AsHashtable -ErrorAction SilentlyContinue | ||
} | ||
Else { | ||
$script:resourceStringsTable = $content | ConvertFrom-Json -ErrorAction SilentlyContinue | ConvertTo-Hashtable | ||
} | ||
} | ||
catch [System.Exception] { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): failed to convert strings to required object." | ||
Throw $_.Exception.Message | ||
} | ||
finally { | ||
If ($Null -ne $script:resourceStringsTable) { | ||
Write-Output -InputObject $script:resourceStringsTable | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Function Invoke-WebContent { | ||
<# | ||
.SYNOPSIS | ||
Return content from Invoke-WebRequest. | ||
#> | ||
[OutputType([Microsoft.PowerShell.Commands.WebResponseObject])] | ||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory = $True, Position = 0)] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] $Uri, | ||
|
||
[Parameter(Mandatory = $True, Position = 0)] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] $ContentType | ||
) | ||
|
||
If ($Null -ne $script:resourceStrings) { | ||
try { | ||
$params = @{ | ||
Uri = $Uri | ||
ContentType = $ContentType | ||
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome | ||
UseBasicParsing = $True | ||
ErrorAction = $script:resourceStrings.Preferences.ErrorAction | ||
} | ||
$Request = Invoke-WebRequest @params | ||
} | ||
catch [System.Net.WebException] { | ||
Write-Warning -Message ($($MyInvocation.MyCommand)) | ||
Write-Warning -Message ([string]::Format("Error : {0}", $_.Exception.Message)) | ||
} | ||
catch [System.Exception] { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): failed to invoke request to: $Uri." | ||
Throw $_.Exception.Message | ||
} | ||
|
||
If ($Request.StatusCode -eq "200") { | ||
Write-Output -InputObject $Request.Content | ||
} | ||
Else { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): no valid response." | ||
} | ||
} | ||
Else { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): unable to retrieve: $Uri." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Function Test-PSCore { | ||
<# | ||
.SYNOPSIS | ||
Returns True if running on PowerShell Core. | ||
#> | ||
[CmdletBinding()] | ||
[OutputType([Boolean])] | ||
Param ( | ||
[Parameter(Mandatory = $False, Position = 0)] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] $Version = '6.0.0' | ||
) | ||
|
||
# Check whether current PowerShell environment matches or is higher than $Version | ||
If (($PSVersionTable.PSVersion -ge [Version]::Parse($Version)) -and ($PSVersionTable.PSEdition -eq "Core")) { | ||
Write-Output -InputObject $True | ||
} | ||
Else { | ||
Write-Output -InputObject $False | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
Function Get-AdobeAcrobatReaderDC { | ||
<# | ||
.SYNOPSIS | ||
Gets the download URLs for Adobe Reader DC Continuous track installers. | ||
.DESCRIPTION | ||
Gets the download URLs for Adobe Reader DC Continuous track installers for the latest version for Windows and macOS. | ||
.NOTES | ||
Author: Aaron Parker | ||
Twitter: @stealthpuppy | ||
.LINK | ||
https://github.com/aaronparker/Get.Software | ||
.PARAMETER Platform | ||
Return downloads for Windows or macOS platforms. Use "win" or "mac" or specify both to return downloads for both platforms. | ||
.EXAMPLE | ||
Get-AdobeReaderUri -Platform | ||
Description: | ||
Returns an array with installer type, language and download URL for Windows. | ||
.EXAMPLE | ||
Get-AdobeReaderUri -Platform win, mac | ||
Description: | ||
Returns an array with installer type, language and download URL for both Windows and macOS. | ||
#> | ||
[CmdletBinding()] | ||
Param ( | ||
[Parameter()] | ||
[ValidateSet("win", "mac")] | ||
[System.String[]] $Platform = "win" | ||
) | ||
|
||
# Get current version | ||
$Content = Invoke-WebContent -Uri $script:resourceStrings.Applications.AdobeAcrobatReaderDC.Uri ` | ||
-ContentType $script:resourceStrings.Applications.AdobeAcrobatReaderDC.ContentType | ||
$version = $Content.Replace(".", "") | ||
|
||
# Construct download list | ||
If ($Null -ne $version) { | ||
ForEach ($plat in $Platform) { | ||
Switch ($plat) { | ||
"win" { | ||
$ftpUrl = "ftp://ftp.adobe.com/pub/adobe/reader/$plat/AcrobatDC/" | ||
ForEach ($lang in $script:resourceStrings.Applications.AdobeAcrobatReaderDC.Languages) { | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "Windows" | ||
Type = "Installer" | ||
Language = $lang | ||
URL = "$($ftpUrl)$($version)/AcroRdrDC$($version)_$($lang).exe" | ||
} | ||
Write-Output -InputObject $PSObject | ||
} | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "Windows" | ||
Type = "Updater" | ||
Language = "Neutral" | ||
URL = "$($ftpUrl)$($version)/AcroRdrDC$($version).msp" | ||
} | ||
Write-Output -InputObject $PSObject | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "Windows" | ||
Type = "Updater" | ||
Language = "Multi" | ||
URL = "$($ftpUrl)$($version)/AcroRdrDC$($version)_MUI.msp" | ||
} | ||
Write-Output -InputObject $PSObject | ||
} | ||
"mac" { | ||
$ftpUrl = "ftp://ftp.adobe.com/pub/adobe/reader/$plat/AcrobatDC/" | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "macOS" | ||
Type = "Installer" | ||
Language = "Multi" | ||
URL = "$($ftpUrl)$($version)/AcroRdrDC_$($version)_MUI.dmg" | ||
} | ||
Write-Output -InputObject $PSObject | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "macOS" | ||
Type = "Updater" | ||
Language = "Multi" | ||
URL = "$($ftpUrl)$($version)/AcroRdrDCUpd$($version)_MUI.dmg" | ||
} | ||
Write-Output -InputObject $PSObject | ||
$PSObject = [PSCustomObject] @{ | ||
Platform = "macOS" | ||
Type = "Updater" | ||
Language = "Multi" | ||
URL = "$($ftpUrl)$($version)/AcroRdrDCUpd$($version)_MUI.pkg" | ||
} | ||
Write-Output -InputObject $PSObject | ||
} | ||
} | ||
} | ||
} | ||
Else { | ||
Write-Warning -Message "$($MyInvocation.MyCommand): unable to find Adobe Acrobat Reader DC version." | ||
} | ||
} |
Oops, something went wrong.