|
1 | 1 | function Get-OmnissaHorizonClient {
|
2 | 2 | <#
|
3 | 3 | .NOTES
|
4 |
| - Author: Aaron Parker |
| 4 | + Author: Aaron Parker, Dan Gough |
5 | 5 | Twitter: @stealthpuppy
|
6 | 6 | #>
|
7 | 7 | [OutputType([System.Management.Automation.PSObject])]
|
|
13 | 13 | $res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
|
14 | 14 | )
|
15 | 15 |
|
16 |
| - # Get the download group and id |
17 |
| - $Products = Invoke-EvergreenRestMethod -Uri $res.Get.Update.Uri |
18 |
| - $Product = $Products.dlgEditionsLists | Where-Object { $_.name -match $res.Get.Update.Match } |
| 16 | + # $Output = Get-VMwareProductList -Name $res.Get.Download.ProductName | ` |
| 17 | + # Get-VMwareProductDownload | ` |
| 18 | + # Where-Object { $_.URI -match $res.Get.Download.MatchFileTypes } | ` |
| 19 | + # Sort-Object -Property "ReleaseDate" | ` |
| 20 | + # Select-Object -Last 1 | ` |
| 21 | + # ForEach-Object { $_.Version = $_.Version -replace $res.Get.Download.ReplaceText, ""; $_ } |
| 22 | + # Write-Output -InputObject $Output |
19 | 23 |
|
20 |
| - # Build the URL to the downloads list |
21 |
| - $Url = $res.Get.Download.Uri -replace "#cart", $Product.dlgList.code ` |
22 |
| - -replace "#pid", $Product.dlgList.productId ` |
23 |
| - -replace "#rpid", $Product.dlgList.releasePackageId |
| 24 | + $params = @{ |
| 25 | + Uri = $res.Get.Download.Uri |
| 26 | + } |
| 27 | + $Response = Invoke-EvergreenRestMethod @params |
| 28 | + $Product = $Response.dlgEditionsLists.Where({ $_.name -eq $res.Get.Download.ProductName }).dlgList |
| 29 | + |
| 30 | + $params = @{ |
| 31 | + Uri = $res.Get.Download.QueryUri -replace "#ProductCode", $Product.code ` |
| 32 | + -replace "#ProductId", $Product.productId ` |
| 33 | + -replace "#PackageId", $Product.releasePackageId |
| 34 | + } |
| 35 | + $details = Invoke-EvergreenRestMethod @params |
| 36 | + |
| 37 | + foreach ($File in $details.downloadFiles) { |
24 | 38 |
|
25 |
| - # Get the download list |
26 |
| - $Downloads = Invoke-EvergreenRestMethod -Uri $Url |
| 39 | + $InternalVersion = [RegEx]::Match($File.thirdPartyDownloadUrl, $res.Get.Download.MatchVersion).Captures.Groups[1].Value |
27 | 40 |
|
28 |
| - # Construct the output; Return the custom object to the pipeline |
29 |
| - foreach ($File in $Downloads.downloadFiles) { |
30 |
| - [PSCustomObject] @{ |
31 |
| - Version = $File.version |
32 |
| - Build = $File.build |
33 |
| - Date = $File.releaseDate |
34 |
| - Sha256 = $File.sha256checksum |
35 |
| - Type = Get-FileType -File $File.thirdPartyDownloadUrl |
36 |
| - URI = $File.thirdPartyDownloadUrl |
37 |
| - } | Write-Output |
| 41 | + $PSObject = [PSCustomObject] @{ |
| 42 | + Version = $File.version |
| 43 | + InternalVersion = "$InternalVersion-$($File.build)" |
| 44 | + Date = ConvertTo-DateTime -DateTime $File.releaseDate -Pattern $res.Get.Download.DateFormat |
| 45 | + Sha256 = $File.sha256checksum |
| 46 | + Size = $File.fileSize |
| 47 | + Type = Get-FileType -File $File.thirdPartyDownloadUrl |
| 48 | + URI = $File.thirdPartyDownloadUrl |
| 49 | + } |
| 50 | + Write-Output -InputObject $PSObject |
38 | 51 | }
|
39 | 52 | }
|
0 commit comments