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
5 changes: 5 additions & 0 deletions powershell-adapter/psDscAdapter/powershell.resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ if ($Operation -eq 'ClearCache') {
exit 0
}

if ($PSVersionTable.PSVersion.Major -le 5) {
# For Windows PowerShell, we want to remove any PowerShell 7 paths from PSModulePath
$env:PSModulePath = ($env:PSModulePath -split ';' | Where-Object { $_ -notlike '*\powershell\*' }) -join ';'
}

if ('Validate' -ne $Operation) {
Write-DscTrace -Operation Debug -Message "jsonInput=$jsonInput"

Expand Down
14 changes: 1 addition & 13 deletions powershell-adapter/psDscAdapter/win_psDscAdapter.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,7 @@ function Invoke-DscCacheRefresh {

$refreshCache = $false

$cacheFilePath = if ($IsWindows) {
# PS 6+ on Windows
Join-Path $env:LocalAppData "dsc\PSAdapterCache.json"
}
else {
# either WinPS or PS 6+ on Linux/Mac
if ($PSVersionTable.PSVersion.Major -le 5) {
Join-Path $env:LocalAppData "dsc\WindowsPSAdapterCache.json"
}
else {
Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
}
}
$cacheFilePath = Join-Path $env:LocalAppData "dsc\WindowsPSAdapterCache.json"

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