Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion setup-powershellget/Setup/ShortcutStartup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,25 @@ Param(
[switch]$Install
)

function EnsureRegistryPath
{
$originalpaths = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PSModulePath).PSModulePath
if($originalpaths.Contains("$env:ProgramFiles\WindowsPowerShell\Modules") -eq $false)
{
Write-Output "Fixing PSModulePath"
$newPath = "$originalpaths;$env:ProgramFiles\WindowsPowerShell\Modules"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PSModulePath –Value $newPath
}
else
{
Write-Output "PSModulePath successfuly validated"
}
}

$error.clear()
try {
if ($Install.IsPresent) {
EnsureRegistryPath
Write-Output @"

Finalizing installation of Azure PowerShell.
Expand Down Expand Up @@ -57,4 +73,5 @@ Write-Output "An error occured during installation."
Write-Output $error
Write-Output "Press any key..."
$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
}