Skip to content

Commit a1b723c

Browse files
Merge pull request #34 from PowershellFrameworkCollective/Development
updated install scripts
2 parents adb3979 + 98d3942 commit a1b723c

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

install.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
1717
.PARAMETER UserMode
1818
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.
1923
2024
.PARAMETER Force
2125
The install script will overwrite an existing module.
@@ -28,6 +32,10 @@ Param (
2832
[switch]
2933
$UserMode,
3034

35+
[ValidateSet('AllUsers', 'CurrentUser')]
36+
[string]
37+
$Scope = "AllUsers",
38+
3139
[switch]
3240
$Force
3341
)
@@ -43,6 +51,15 @@ $BaseUrl = "https://github.com/PowershellFrameworkCollective/PSUtil"
4351
$SubFolder = "PSUtil"
4452
#endregion Configuration for cloning script
4553

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+
4663
#region Utility Functions
4764
function Compress-Archive
4865
{
@@ -2349,7 +2366,7 @@ function Write-LocalMessage
23492366
[string]$Message
23502367
)
23512368

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" }
23532370
else { Write-Host $Message }
23542371
}
23552372
#endregion Utility Functions
@@ -2378,7 +2395,7 @@ try
23782395

23792396
# Determine output path
23802397
$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)" }
23822399
if ($PSVersionTable.PSVersion.Major -ge 5) { $path += "\$moduleVersion" }
23832400

23842401
if ((Test-Path $path) -and (-not $Force))

0 commit comments

Comments
 (0)