|
1 | 1 | function Test-Tooling { |
| 2 | + [CmdletBinding(SupportsShouldProcess = $true)] |
| 3 | + param( |
| 4 | + [Parameter(Mandatory = $false)] |
| 5 | + [switch]$skipAlzModuleVersionCheck |
| 6 | + ) |
| 7 | + |
2 | 8 | $checkResults = @() |
3 | 9 | $hasFailure = $false |
4 | 10 |
|
@@ -149,24 +155,38 @@ function Test-Tooling { |
149 | 155 | } |
150 | 156 | } |
151 | 157 |
|
152 | | - # Check if latest ALZ module is installed |
153 | | - Write-Verbose "Checking ALZ module version" |
154 | | - $alzModuleCurrentVersion = Get-InstalledModule -Name ALZ |
155 | | - $alzModuleLatestVersion = Find-Module -Name ALZ |
156 | | - if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) { |
157 | | - $checkResults += @{ |
158 | | - message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'." |
159 | | - result = "Failure" |
160 | | - } |
161 | | - $hasFailure = $true |
| 158 | + if($skipAlzModuleVersionCheck.IsPresent) { |
| 159 | + Write-Verbose "Skipping ALZ module version check" |
162 | 160 | } else { |
163 | | - $checkResults += @{ |
164 | | - message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))." |
165 | | - result = "Success" |
| 161 | + # Check if latest ALZ module is installed |
| 162 | + Write-Verbose "Checking ALZ module version" |
| 163 | + $alzModuleCurrentVersion = Get-InstalledModule -Name ALZ -ErrorAction SilentlyContinue |
| 164 | + if($null -eq $alzModuleCurrentVersion) { |
| 165 | + $checkResults += @{ |
| 166 | + message = "ALZ module is not correctly installed. Please install the latest version using 'Install-Module ALZ'." |
| 167 | + result = "Failure" |
| 168 | + } |
| 169 | + $hasFailure = $true |
| 170 | + } |
| 171 | + $alzModuleLatestVersion = Find-Module -Name ALZ |
| 172 | + if ($null -ne $alzModuleCurrentVersion) { |
| 173 | + if ($alzModuleCurrentVersion.Version -lt $alzModuleLatestVersion.Version) { |
| 174 | + $checkResults += @{ |
| 175 | + message = "ALZ module is not the latest version. Your version: $($alzModuleCurrentVersion.Version), Latest version: $($alzModuleLatestVersion.Version). Please update to the latest version using 'Update-Module ALZ'." |
| 176 | + result = "Failure" |
| 177 | + } |
| 178 | + $hasFailure = $true |
| 179 | + } else { |
| 180 | + $checkResults += @{ |
| 181 | + message = "ALZ module is the latest version ($($alzModuleCurrentVersion.Version))." |
| 182 | + result = "Success" |
| 183 | + } |
| 184 | + } |
166 | 185 | } |
167 | 186 | } |
168 | 187 |
|
169 | 188 | Write-Verbose "Showing check results" |
| 189 | + Write-Verbose $(ConvertTo-Json $checkResults -Depth 100) |
170 | 190 | $checkResults | ForEach-Object {[PSCustomObject]$_} | Format-Table -Property @{ |
171 | 191 | Label = "Check Result"; Expression = { |
172 | 192 | switch ($_.result) { |
|
0 commit comments