MEM-Zone / MEM.Zone

Our ♡ collection of PowerShell scripts and Endpoint Management related stuff 🐵
https://MEM.Zone/GIT
GNU General Public License v3.0
97 stars 10 forks source link

Get-CimInstance : Invalid class | HRESULT 0x80041010 #14

Closed idrositis closed 1 year ago

idrositis commented 2 years ago

After some latest updates on our systems (after Sep/2021), we are getting the below error while running the script Clean-CMClientCache.ps1...

PS C:\Tools> .\Clean-CMClientCache.ps1
Get-CimInstance : Invalid class
At C:\Tools\Clean-CMClientCache.ps1:1601 char:32
+ ... SuperPeer = Get-CimInstance -Namespace 'root\ccm\Policy\Machine\Actua ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (root\ccm\Policy...eerClientConfig:String) [Get-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

[10-29-2021 13:10:53.315] [Main:CleanupResult] [Clean-CMClientCache] :: TotalDeletedSize: 0

Which is basically triggered by this call...

PS C:\Tools> Get-CimInstance -Namespace 'root\ccm\Policy\Machine\ActualConfig' -ClassName 'CCM_SuperPeerClientConfig' -Verbose:$true
VERBOSE: Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\ccm\Policy\Machine\ActualConfig,'className' =
CCM_SuperPeerClientConfig'.
Get-CimInstance : Invalid class
At line:1 char:1
+ Get-CimInstance -Namespace 'root\ccm\Policy\Machine\ActualConfig' -Cl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (root\ccm\Policy...eerClientConfig:String) [Get-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

VERBOSE: Operation 'Enumerate CimInstances' complete.

On Windows Server 2012 R2 and Windows Server 2016 machines.

For PS version 5.1+

PS C:\Tools> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Ioan-Popovici commented 2 years ago

Weird, I'll try to reproduce.

Ioan-Popovici commented 1 year ago

Seems to be happening if peer cache is not enabled

Ioan-Popovici commented 1 year ago

Invoke-CCMCacheCleanup release history

6.0.0 - 2023-07-28