diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index 9c5e77b44433..9d2228f0d5a6 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -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. @@ -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") -} \ No newline at end of file +} +