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') {
45
45
exit 0
46
46
}
47
47
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
+
48
53
if (' Validate' -ne $Operation ) {
49
54
Write-DscTrace - Operation Debug - Message " jsonInput=$jsonInput "
50
55
Original file line number Diff line number Diff line change @@ -54,19 +54,7 @@ function Invoke-DscCacheRefresh {
54
54
55
55
$refreshCache = $false
56
56
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"
70
58
71
59
if (Test-Path $cacheFilePath ) {
72
60
" Reading from Get-DscResource cache file $cacheFilePath " | Write-DscTrace
You can’t perform that action at this time.
0 commit comments