You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ALZ/Private/Tools/Test-Tooling.ps1
+33-14Lines changed: 33 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -157,12 +157,22 @@ function Test-Tooling {
157
157
}
158
158
}
159
159
160
+
$currentScope="CurrentUser"
161
+
160
162
if($skipAlzModuleVersionCheck.IsPresent) {
161
163
Write-Verbose"Skipping ALZ module version check"
162
164
} else {
163
165
# Check if latest ALZ module is installed
164
166
Write-Verbose"Checking ALZ module version"
165
-
$alzModuleCurrentVersion=Get-InstalledPSResource-Name ALZ |Select-Object-Property Name, Version |Sort-Object Version -Descending |Select-Object-First 1
167
+
$alzModuleCurrentVersion=Get-InstalledPSResource-Name ALZ 2>$null|Select-Object-Property Name, Version |Sort-Object Version -Descending |Select-Object-First 1
168
+
if($null-eq$alzModuleCurrentVersion) {
169
+
Write-Verbose"ALZ module not found in CurrentUser scope, checking AllUsers scope"
170
+
$alzModuleCurrentVersion=Get-InstalledPSResource-Name ALZ -Scope AllUsers 2>$null|Select-Object-Property Name, Version |Sort-Object Version -Descending |Select-Object-First 1
171
+
if($null-ne$alzModuleCurrentVersion) {
172
+
Write-Verbose"ALZ module found in AllUsers scope"
173
+
$currentScope="AllUsers"
174
+
}
175
+
}
166
176
167
177
if($null-eq$alzModuleCurrentVersion) {
168
178
$checkResults+=@{
@@ -191,31 +201,40 @@ function Test-Tooling {
191
201
# Check if powershell-yaml module is installed (only when YAML files are being used)
$yamlModule=Get-InstalledPSResource-Name powershell-yaml 2>$null|Select-Object-Property Name, Version |Sort-Object Version -Descending |Select-Object-First 1
205
+
if($null-eq$yamlModule) {
206
+
Write-Verbose"powershell-yaml module not found in CurrentUser scope, checking AllUsers scope"
207
+
$yamlModule=Get-InstalledPSResource-Name powershell-yaml -Scope AllUsers 2>$null|Select-Object-Property Name, Version |Sort-Object Version -Descending |Select-Object-First 1
208
+
}
209
+
195
210
if ($yamlModule) {
196
211
$checkResults+=@{
197
212
message="powershell-yaml module is installed (version $($yamlModule.Version))."
Write-Verbose"Failed to install powershell-yaml module due to permission issues at $currentScope scope."
209
220
$checkResults+=@{
210
-
message="powershell-yaml module was not installed, but has been successfully installed (version $((Get-InstalledPSResource-Name powershell-yaml).Version))."
211
-
result="Success"
221
+
message="powershell-yaml module is not installed. Please install it using an admin terminal with 'Install-PSResource powershell-yaml -Scope $currentScope'. Could not install due to permission issues."
222
+
result="Failure"
212
223
}
213
-
} else {
224
+
$hasFailure=$true
225
+
} elseif ($null-ne$installResult) {
226
+
Write-Verbose"Failed to install powershell-yaml module: $installResult"
214
227
$checkResults+=@{
215
-
message="powershell-yaml module is not installed. Please install it using 'Install-PSResource powershell-yaml'."
228
+
message="powershell-yaml module is not installed. Please install it using 'Install-PSResource powershell-yaml -Scope $currentScope'. Attempted installation error: $installResult"
0 commit comments