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: DevSetup/Private/Providers/Powershell/Install-PowershellModule.ps1
+51-34Lines changed: 51 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -97,54 +97,71 @@ Function Install-PowershellModule {
97
97
[ValidateSet('CurrentUser','AllUsers')]
98
98
[String] $Scope='CurrentUser'
99
99
)
100
-
100
+
101
101
try {
102
102
# Check if running as administrator only when installing for all users
103
103
if ($Scope-eq'AllUsers'-and (-not (Test-RunningAsAdmin))) {
104
-
throw"PowerShell module installation to AllUsers scope requires administrator privileges. Please run as administrator or use CurrentUser scope."
105
-
}
106
-
107
-
$installParams=@{
108
-
Name=$ModuleName
109
-
Force=$Force
110
-
Scope=$Scope
111
-
AllowClobber=$AllowClobber
112
-
SkipPublisherCheck=$true
104
+
Write-StatusMessage"PowerShell module installation to AllUsers scope requires administrator privileges. Please run as administrator or use CurrentUser scope."-Verbosity Error
105
+
return$false
113
106
}
107
+
} catch {
108
+
Write-StatusMessage"Failed to validate administrator privileges: $_"-Verbosity Error
0 commit comments