I found an issue if you have no users that have logged onto the device yet, at least in my environment, you get an error when trying to populate the $Packages variable. The error is a generic failure when trying to access the namespace. I would suggest adding ErrorAction SilentlyContinue to that line as so. I will try to attach the full error if I can get to it.
$Packages = Get-CimInstance -Namespace 'Root\ccm\ClientSDK' -ClassName 'CCM_Program' -Verbose:$false -ErrorAction SilenetlyContinue
Howdy Ioan,
I found an issue if you have no users that have logged onto the device yet, at least in my environment, you get an error when trying to populate the $Packages variable. The error is a generic failure when trying to access the namespace. I would suggest adding ErrorAction SilentlyContinue to that line as so. I will try to attach the full error if I can get to it. $Packages = Get-CimInstance -Namespace 'Root\ccm\ClientSDK' -ClassName 'CCM_Program' -Verbose:$false -ErrorAction SilenetlyContinue