16
16
17
17
. PARAMETER UserMode
18
18
The downloaded module will be moved to the user profile, rather than program files.
19
+
20
+ . PARAMETER Scope
21
+ By default, the downloaded module will be moved to program files.
22
+ Setting this to 'CurrentUser' installs to the userprofile of the current user.
19
23
20
24
. PARAMETER Force
21
25
The install script will overwrite an existing module.
@@ -28,6 +32,10 @@ Param (
28
32
[switch ]
29
33
$UserMode ,
30
34
35
+ [ValidateSet (' AllUsers' , ' CurrentUser' )]
36
+ [string ]
37
+ $Scope = " AllUsers" ,
38
+
31
39
[switch ]
32
40
$Force
33
41
)
@@ -43,6 +51,15 @@ $BaseUrl = "https://github.com/PowershellFrameworkCollective/PSModuleDevelopment
43
51
$SubFolder = " PSModuleDevelopment"
44
52
# endregion Configuration for cloning script
45
53
54
+ # region Parameter Calculation
55
+ $doUserMode = $false
56
+ if ($UserMode ) { $doUserMode = $true }
57
+ if ($install_CurrentUser ) { $doUserMode = $true }
58
+ if ($Scope -eq ' CurrentUser' ) { $doUserMode = $true }
59
+
60
+ if ($install_Branch ) { $Branch = $install_Branch }
61
+ # endregion Parameter Calculation
62
+
46
63
# region Utility Functions
47
64
function Compress-Archive
48
65
{
@@ -2349,7 +2366,7 @@ function Write-LocalMessage
2349
2366
[string ]$Message
2350
2367
)
2351
2368
2352
- if (Test-Path function: Write-PSFMessage ) { Write-PSFMessage - Level Important - Message $Message }
2369
+ if (([ System.Management.Automation.PSTypeName ] ' PSFramework.Commands.WritePSFMessageCommand ' ).Type) { Write-PSFMessage - Level Important - Message $Message - FunctionName " Install- $ModuleName " }
2353
2370
else { Write-Host $Message }
2354
2371
}
2355
2372
# endregion Utility Functions
@@ -2378,7 +2395,7 @@ try
2378
2395
2379
2396
# Determine output path
2380
2397
$path = " $ ( $env: ProgramFiles ) \WindowsPowerShell\Modules\$ ( $ModuleName ) "
2381
- if ($UserMode ) { $path = " $ ( $HOME ) \Documents\WindowsPowerShell \Modules\$ ( $ModuleName ) " }
2398
+ if ($doUserMode ) { $path = " $ ( Split-Path $profile .CurrentUserAllHosts ) \Modules\$ ( $ModuleName ) " }
2382
2399
if ($PSVersionTable.PSVersion.Major -ge 5 ) { $path += " \$moduleVersion " }
2383
2400
2384
2401
if ((Test-Path $path ) -and (-not $Force ))
@@ -2411,4 +2428,4 @@ catch
2411
2428
Remove-Item - Path " $ ( $env: TEMP ) \$ ( $ModuleName ) .zip" - Force
2412
2429
2413
2430
throw
2414
- }
2431
+ }
0 commit comments