Skip to content

Commit 9b32f01

Browse files
author
Hovsep
committed
Merge pull request #1005 from hovsepm/dev
[#104454614] Fixed broken environment caused by v 0.9.8 uninstall
2 parents ec3088c + 916c16c commit 9b32f01

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

setup-powershellget/Setup/ShortcutStartup.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,25 @@ Param(
1717
[switch]$Install
1818
)
1919

20+
function EnsureRegistryPath
21+
{
22+
$originalpaths = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PSModulePath).PSModulePath
23+
if($originalpaths.Contains("$env:ProgramFiles\WindowsPowerShell\Modules") -eq $false)
24+
{
25+
Write-Output "Fixing PSModulePath"
26+
$newPath = "$originalpaths;$env:ProgramFiles\WindowsPowerShell\Modules"
27+
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PSModulePath –Value $newPath
28+
}
29+
else
30+
{
31+
Write-Output "PSModulePath successfuly validated"
32+
}
33+
}
34+
2035
$error.clear()
2136
try {
2237
if ($Install.IsPresent) {
38+
EnsureRegistryPath
2339
Write-Output @"
2440
2541
Finalizing installation of Azure PowerShell.
@@ -57,4 +73,5 @@ Write-Output "An error occured during installation."
5773
Write-Output $error
5874
Write-Output "Press any key..."
5975
$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
60-
}
76+
}
77+

0 commit comments

Comments
 (0)