Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion powershell-adapter/Tests/win_powershellgroup.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PSClassResource {
New-Item -Path $modulePath -ItemType File -Value $module -Force | Out-Null
}

$env:PSModulePath = $windowsPowerShellPath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$env:PSModulePath = $windowsPowerShellPath + [System.IO.Path]::PathSeparator + $env:PSModulePath + [System.IO.Path]::PathSeparator
}

AfterAll {
Expand Down
16 changes: 16 additions & 0 deletions powershell-adapter/psDscAdapter/win_psDscAdapter.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ function Invoke-DscCacheRefresh {
$namedModules = [System.Collections.Generic.List[Object]]::new()
$cacheFilePath = Join-Path $env:LocalAppData "dsc\WindowsPSAdapterCache.json"

# Repair PSModulePath to not contain empty entries
Repair-ValidPSModulePath

if (Test-Path $cacheFilePath) {
"Reading from Get-DscResource cache file $cacheFilePath" | Write-DscTrace

Expand Down Expand Up @@ -701,6 +704,19 @@ function GetClassBasedCapabilities {
}
}

function Repair-ValidPSModulePath {
[CmdletBinding()]
param()

end {
if (($env:PSModulePath -split [System.IO.Path]::PathSeparator) -contains '') {
"Removing empty entry from PSModulePath: '$env:PSModulePath'" | Write-DscTrace -Operation Debug
$env:PSModulePath = [String]::Join([System.IO.Path]::PathSeparator, ($env:PSModulePath.Split([System.IO.Path]::PathSeparator, [System.StringSplitOptions]::RemoveEmptyEntries))).TrimEnd([System.IO.Path]::PathSeparator)
}
}
}


# cached resource
class dscResourceCacheEntry {
[string] $Type
Expand Down
Loading