@@ -60,8 +60,8 @@ function Invoke-DscCacheRefresh {
6060 $namedModules = [System.Collections.Generic.List [Object ]]::new()
6161 $cacheFilePath = Join-Path $env: LocalAppData " dsc\WindowsPSAdapterCache.json"
6262
63- # Reset PSModulePath to not contain empty entries
64- Set -ValidPSModulePath
63+ # Repair PSModulePath to not contain empty entries
64+ Repair -ValidPSModulePath
6565
6666 if (Test-Path $cacheFilePath ) {
6767 " Reading from Get-DscResource cache file $cacheFilePath " | Write-DscTrace
@@ -247,10 +247,10 @@ function Invoke-DscCacheRefresh {
247247 }
248248
249249 $dscResourceCacheEntries.Add ([dscResourceCacheEntry ]@ {
250- Type = " $moduleName /$ ( $dscResource.Name ) "
251- DscResourceInfo = $DscResourceInfo
252- LastWriteTimes = $lastWriteTimes
253- })
250+ Type = " $moduleName /$ ( $dscResource.Name ) "
251+ DscResourceInfo = $DscResourceInfo
252+ LastWriteTimes = $lastWriteTimes
253+ })
254254 }
255255
256256 if ($namedModules.Count -gt 0 ) {
@@ -704,15 +704,14 @@ function GetClassBasedCapabilities {
704704 }
705705}
706706
707- function Set -ValidPSModulePath {
707+ function Repair -ValidPSModulePath {
708708 [CmdletBinding ()]
709709 param ()
710710
711711 end {
712712 if (($env: PSModulePath -split [System.IO.Path ]::PathSeparator) -contains ' ' ) {
713713 " Removing empty entry from PSModulePath: '$env: PSModulePath '" | Write-DscTrace - Operation Debug
714- $env: PSModulePath = ($env: PSModulePath -split [System.IO.Path ]::PathSeparator |
715- Where-Object { $_ -ne ' ' }) -join [System.IO.Path ]::PathSeparator
714+ $env: PSModulePath = [String ]::Join([System.IO.Path ]::PathSeparator, ($env: PSModulePath.Split ([System.IO.Path ]::PathSeparator, [System.StringSplitOptions ]::RemoveEmptyEntries)))
716715 }
717716 }
718717}
0 commit comments