Skip to content

[#104454614] Fixed broken environment caused by v 0.9.8 uninstall #1005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2015
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")
}
}