Windows 11 Powershell Null Get-CimInstance
Hi! So I’m trying to create a Kiosk for a downloaded remote desktop application, but every time I run the script, I get the following errors:
The property ‘Configuration’ cannot be found on this object. Verify that the property exists and can be set.
At line:28 char:1
+ $obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAcc …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Set-CimInstance : Cannot bind argument to parameter ‘InputObject’ because it is null.
At line:29 char:30
+ Set-CimInstance -CimInstance $obj
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Set-CimInstance], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Management.Infrastructure.CimCm
dlets.SetCimInstanceCommand
This is the full script:
$user = “RemoteDesktopUser”
$userDesc = “Remote Desktop”
New-LocalUser -Name $user -NoPassword -AccountNeverExpires -UserMayNotChangePassword -Description $userDesc | Set-LocalUser -PasswordNeverExpires $true
Add-LocalGroupMember -SID S-1-5-32-545 -Member $user
$Sid = (Get-LocalUser -Name $user).SID.Value
$assignedAccessConfiguration = @”
<?xml version=”1.0″ encoding=”utf-8″?>
<AssignedAccessConfiguration xmlns=”http://schemas.microsoft.com/AssignedAccess/2017/config” xmlns:rs5=”http://schemas.microsoft.com/AssignedAccess/201810/config” xmlns:v4=”http://schemas.microsoft.com/AssignedAccess/2021/config” xmlns:v5=”http://schemas.microsoft.com/AssignedAccess/2022/config“>
<Profiles>
<Profile Id=”{$Sid}”>
<KioskModeApp v4:ClassicAppPath=”%Program Files%WindowsApps%RemoteDesktop%RdClient.Windows.exe” v4:ClassicAppArguments=”–kiosk https://www.contoso.com/ –edge-kiosk-type=fullscreen –kiosk-idle-timeout-minutes=5″ />
<v4:BreakoutSequence Key=”Ctrl+A” />
</Profile>
</Profiles>
<Configs>
<Config>
<Account>”{$user}”</Account>
<DefaultProfile Id=”{$Sid}” />
</Config>
</Configs>
</AssignedAccessConfiguration>
“@
$namespaceName=”rootcimv2mdmdmmap”
$className=”MDM_AssignedAccess”
$obj = Get-CimInstance -Namespace $namespaceName -ClassName $className
$obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAccessConfiguration)
Set-CimInstance -CimInstance $obj
Any help is appreciated!
Hi! So I’m trying to create a Kiosk for a downloaded remote desktop application, but every time I run the script, I get the following errors: The property ‘Configuration’ cannot be found on this object. Verify that the property exists and can be set.At line:28 char:1+ $obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAcc …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (:) [], RuntimeException+ FullyQualifiedErrorId : PropertyNotFound Set-CimInstance : Cannot bind argument to parameter ‘InputObject’ because it is null.At line:29 char:30+ Set-CimInstance -CimInstance $obj+ ~~~~+ CategoryInfo : InvalidData: (:) [Set-CimInstance], ParameterBindingValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand This is the full script: $user = “RemoteDesktopUser”$userDesc = “Remote Desktop”New-LocalUser -Name $user -NoPassword -AccountNeverExpires -UserMayNotChangePassword -Description $userDesc | Set-LocalUser -PasswordNeverExpires $trueAdd-LocalGroupMember -SID S-1-5-32-545 -Member $user$Sid = (Get-LocalUser -Name $user).SID.Value $assignedAccessConfiguration = @”<?xml version=”1.0″ encoding=”utf-8″?><AssignedAccessConfiguration xmlns=”http://schemas.microsoft.com/AssignedAccess/2017/config” xmlns:rs5=”http://schemas.microsoft.com/AssignedAccess/201810/config” xmlns:v4=”http://schemas.microsoft.com/AssignedAccess/2021/config” xmlns:v5=”http://schemas.microsoft.com/AssignedAccess/2022/config”> <Profiles> <Profile Id=”{$Sid}”> <KioskModeApp v4:ClassicAppPath=”%Program Files%WindowsApps%RemoteDesktop%RdClient.Windows.exe” v4:ClassicAppArguments=”–kiosk https://www.contoso.com/ –edge-kiosk-type=fullscreen –kiosk-idle-timeout-minutes=5″ /> <v4:BreakoutSequence Key=”Ctrl+A” /> </Profile> </Profiles> <Configs> <Config> <Account>”{$user}”</Account> <DefaultProfile Id=”{$Sid}” /> </Config> </Configs></AssignedAccessConfiguration>”@ $namespaceName=”rootcimv2mdmdmmap”$className=”MDM_AssignedAccess”$obj = Get-CimInstance -Namespace $namespaceName -ClassName $className$obj.Configuration = [System.Net.WebUtility]::HtmlEncode($assignedAccessConfiguration)Set-CimInstance -CimInstance $obj Any help is appreciated! Read More