Forum Discussion
Artemis23
Jul 27, 2024Copper Contributor
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 ...
sdtslmn
Jul 30, 2024MCT
here is the updated version of your script please check and update if you have further problems
$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="%ProgramFiles%\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>
"@
# Use the correct namespace
$namespaceName = "root\Microsoft\Windows\AssignedAccess"
$className = "AssignedAccessConfiguration"
# Create a new instance if none exists
$obj = Get-CimInstance -Namespace $namespaceName -ClassName $className -ErrorAction SilentlyContinue
if (!$obj) {
$obj = New-CimInstance -Namespace $namespaceName -ClassName $className
}
# Set the configuration using the appropriate property
$obj.Xml = $assignedAccessConfiguration
# Save the configuration
Set-CimInstance -CimInstance $obj