Skip to content

Commit 5eb0c8b

Browse files
authored
Merge branch 'main' into format-function
2 parents ad736df + aaec641 commit 5eb0c8b

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

powershell-adapter/psDscAdapter/powershell.resource.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
4853
if ('Validate' -ne $Operation) {
4954
Write-DscTrace -Operation Debug -Message "jsonInput=$jsonInput"
5055

powershell-adapter/psDscAdapter/win_psDscAdapter.psm1

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)