Functions/Private/Repair-PSModulePath.ps1
function Get-MyDocumentsPath{ [System.Environment]::GetFolderPath("MyDocuments") } function Repair-PSModulePath { $Edition = Get-PSEdition Write-verbose "MyDocuments path is $(Get-MyDocumentsPath)" Write-verbose "HOME path is $($env:HOME)" Write-verbose "HOMEPATH path is $($env:HOMEPATH)" $homePath = Get-MyDocumentsPath if ($homePath -eq "") { $homePath = $HOME } if ($Edition -eq "Core") { $mydocsPath = join-path $homepath "PowerShell/Modules" } else { $mydocsPath = join-path $homepath "WindowsPowerShell/Modules" } If ("$($env:PSModulePath)".Split([IO.Path]::PathSeparator) -notcontains $mydocsPath) { Write-Verbose "Adding LocalModule folder to PSModulePath" $env:PSModulePath = "$mydocsPath$([IO.Path]::PathSeparator)$($env:PSModulePath)" } } |