-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
Whenever a user removes a module from the $env:PSMODULEPATH and the caching was already done, an error is thrown:
Get-Item: Cannot find path 'C:\Program Files\PowerShell\Modules\Microsoft.WinGet.DSC\1.8.1911\Microsoft.WinGet.DSC.psd1' because
it does not exist.
InvalidOperation: You cannot call a method on a null-valued expression.
Get-Item cannot operate on null values. Would it be better to change this:
if (-not ((Get-Item $_.Name).LastWriteTime.Equals([DateTime]$_.Value)))
{
"Detected stale cache entry '$($_.Name)'" | Write-DscTrace
$refreshCache = $true
break
}To:
if ($_.Name)
{
if (-not ((Get-Item $_.Name).LastWriteTime.Equals([DateTime]$_.Value)))
{
"Detected stale cache entry '$($_.Name)'" | Write-DscTrace
$refreshCache = $true
break
}
}Steps to reproduce
- Install Microsoft.WinGet.DSC
- Execute
dsc resource list --adapter Microsoft.DSC/PowerShell - Remove Microsoft.WinGet.DSc
- Execute
dsc resource list --adapter Microsoft.DSC/PowerShellonce more
No data is returned.
Expected behavior
Returned list of PowerShell resourcesActual behavior
Nothing happensError details
Get-Item: Cannot find path 'C:\Program Files\PowerShell\Modules\Microsoft.WinGet.DSC\1.8.1911\Microsoft.WinGet.DSC.psd1' because
it does not exist.
InvalidOperation: You cannot call a method on a null-valued expression.Environment data
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Version
dsc 3.0.0-preview.8
Visuals
No response