@@ -10,7 +10,7 @@ function Get-LatestRelease {
10
10
File name: Get-LatestRelease.ps1
11
11
Author: Florian Carrier
12
12
Creation date: 2024-09-03
13
- Last modified: 2024-09-04
13
+ Last modified: 2024-10-08
14
14
15
15
. LINK
16
16
https://us1.alteryxcloud.com/license-portal/api/swagger-ui/index.html
@@ -81,38 +81,68 @@ function Get-LatestRelease {
81
81
# Parse release date
82
82
$Response.Add (" Date" , $Release.releaseDate )
83
83
# Fetch corresponding product installer download URL
84
- if ($Patch ) {
85
- $Product = " $ProductID Patch"
86
- } else {
87
- $Product = $ProductID
84
+ switch ($ProductID ) {
85
+ " Alteryx Designer" {
86
+ if ($Patch ) {
87
+ $Product = " $ProductID (Admin version) Patch"
88
+ } else {
89
+ $Product = " $ProductID (Admin version)"
90
+ }
91
+ }
92
+ " Alteryx Server" {
93
+ if ($Patch ) {
94
+ $Product = " $ProductID Patch"
95
+ } else {
96
+ $Product = $ProductID
97
+ }
98
+ }
99
+ " Alteryx Intelligence Suite" {
100
+ $Product = " $ProductID (Admin)"
101
+ }
102
+ " Data Packages" {
103
+ # TODO handle asynchronous release cycle & demographic packages
104
+ $Product = $ProductID.Replace (" Spatial" , " Location Insights" )
105
+ }
106
+ default {
107
+ Write-Log - Type " WARN" - Message " $ProductID is not (yet) supported"
108
+ $Product = $ProductID
109
+ }
88
110
}
89
111
$Installer = Get-AlteryxProductEditions - AccountID $AccountID - Token $Token - ReleaseID $Release.id | Where-Object - Property " description" -EQ - Value $Product
90
112
# Parse file name
91
- if ((Split-Path - Path $Installer.downloadLink - Leaf) -match ' (.+?\.exe)' ) {
92
- $FileName = $matches [1 ]
93
- } else {
94
- Write-Log - Type " WARN" - Message " Unable to parse file name"
95
- $FileName = $Null
96
- }
97
- $Response.Add (" FileName" , $FileName )
98
- # Parse complete version number
99
- if ($Installer.downloadLink -match ' _(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe' ) {
100
- $ParsedVersion = $matches [1 ]
101
- # Hotfix for messed up patch version formatting
102
- if ($Patch ) {
103
- $PatchVersion = Select-String - InputObject $ParsedVersion - Pattern ' (\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' - AllMatches
104
- $Version = [System.String ]::Concat($PatchVersion.Matches.Groups [1 ].Value, $PatchVersion.Matches.Groups [2 ].Value)
113
+ try {
114
+ if ((Split-Path - Path $Installer.downloadLink - Leaf) -match ' (.+?\.exe)' ) {
115
+ $FileName = $matches [1 ]
105
116
} else {
106
- $Version = $ParsedVersion
117
+ Write-Log - Type " WARN" - Message " Unable to parse file name"
118
+ $FileName = $Null
107
119
}
108
- } else {
109
- $Version = $Release.version
120
+ $Response.Add (" FileName" , $FileName )
121
+ # Parse complete version number
122
+ if ($Installer.downloadLink -match ' _(\d+\.\d+(\.\d+)?(\.\d+)?(\.\d+)?)\.exe' ) {
123
+ $ParsedVersion = $matches [1 ]
124
+ # Hotfix for messed up patch version formatting
125
+ if ($Patch ) {
126
+ $PatchVersion = Select-String - InputObject $ParsedVersion - Pattern ' (\d+\.\d+\.\d+)(?:\.\d+)(\.\d+)' - AllMatches
127
+ $Version = [System.String ]::Concat($PatchVersion.Matches.Groups [1 ].Value, $PatchVersion.Matches.Groups [2 ].Value)
128
+ } else {
129
+ $Version = $ParsedVersion
130
+ }
131
+ } else {
132
+ $Version = $Release.version
133
+ }
134
+ $Response.Add (" Version" , $Version )
135
+ # Expose direct download link
136
+ $Response.Add (" URL" , $Installer.downloadLink )
137
+ # Return formatted response object
138
+ Write-Log - Type " DEBUG" - Message $Response
139
+ }
140
+ catch {
141
+ Write-Log - Type " ERROR" - Message " Failed to fetch latest release of $ProductID "
142
+ $Response = $null
110
143
}
111
- $Response.Add (" Version" , $Version )
112
- # Expose direct download link
113
- $Response.Add (" URL" , $Installer.downloadLink )
114
- # Return formatted response object
115
- Write-Log - Type " DEBUG" - Message $Response
144
+ }
145
+ End {
116
146
return $Response
117
147
}
118
148
}
0 commit comments