File tree Expand file tree Collapse file tree 2 files changed +6
-13
lines changed
powershell-adapter/psDscAdapter Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ if ($Operation -eq 'ClearCache') {
4545 exit 0
4646}
4747
48+ if ($PSVersionTable.PSVersion.Major -le 5 ) {
49+ # For Windows PowerShell, we want to remove any PowerShell 7 paths from PSModulePath
50+ $env: PSModulePath = ($env: PSModulePath -split ' ;' | Where-Object { $_ -notlike ' *\powershell\*' }) -join ' ;'
51+ }
52+
4853if (' Validate' -ne $Operation ) {
4954 Write-DscTrace - Operation Debug - Message " jsonInput=$jsonInput "
5055
Original file line number Diff line number Diff line change @@ -54,19 +54,7 @@ function Invoke-DscCacheRefresh {
5454
5555 $refreshCache = $false
5656
57- $cacheFilePath = if ($IsWindows ) {
58- # PS 6+ on Windows
59- Join-Path $env: LocalAppData " dsc\PSAdapterCache.json"
60- }
61- else {
62- # either WinPS or PS 6+ on Linux/Mac
63- if ($PSVersionTable.PSVersion.Major -le 5 ) {
64- Join-Path $env: LocalAppData " dsc\WindowsPSAdapterCache.json"
65- }
66- else {
67- Join-Path $env: HOME " .dsc" " PSAdapterCache.json"
68- }
69- }
57+ $cacheFilePath = Join-Path $env: LocalAppData " dsc\WindowsPSAdapterCache.json"
7058
7159 if (Test-Path $cacheFilePath ) {
7260 " Reading from Get-DscResource cache file $cacheFilePath " | Write-DscTrace
You can’t perform that action at this time.
0 commit comments