Skip to content

Instantly share code, notes, and snippets.

@LoganGray
Last active December 15, 2022 23:02
Show Gist options
  • Save LoganGray/8a95dd0a4a23094bbebfe7cb6b2e3a48 to your computer and use it in GitHub Desktop.
Save LoganGray/8a95dd0a4a23094bbebfe7cb6b2e3a48 to your computer and use it in GitHub Desktop.
kiosk parameter change
#kiosk display timeout
$user = "Kiosk"
$Parm2change = "kiosk-idle-timeout-minutes"
$Parm2changeNewValue ="5"
$Sid = (Get-LocalUser -Name $user).SID.Value
#this part not really relevant - but interesting to return to compare
$version = (Get-ComputerInfo | Select-Object OsBuildNumber).OsBuildNumber
write-output("OS version:"+$version)
$profile = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\AssignedAccessConfiguration\Configs\$Sid" -Name DefaultProfileId
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\AssignedAccessConfiguration\Profiles\$profile\AllowedApps\App0"
#echo $regpath
$argument = (Get-ItemProperty $regpath).Arguments
echo "argument: $argument"
#HKLM:\SOFTWARE\Microsoft\Windows\AssignedAccessConfiguration\Profiles\{1BD00D89-A61C-41C2-B2A5-5C3F50674EF3}\AllowedApps\App0
#Set-ItemProperty -Path $regpath -Name Arguments -Value $newarg
$argArray = $argument -split ("--")
$argArray = $argArray[1..($argArray.Length-1)]
#parm
#value (optional)
$newarg = ""
##foreach item in array
foreach ($element in $argArray)
{
$tmpsplit = $element -split("=")
$parm = $tmpsplit[0]
$valu = $tmpsplit[1]
echo "parm=$parm"
echo "value=$valu"
echo "value len = "$valu.count
if (!$valu) {
$newarg = ($newarg + "--" + $parm)
}
else
{
if ($parm -eq $Parm2change)
{$valu = $Parm2changeNewValue }
$newarg = ($newarg+"--"+$parm+"="+$valu+" ")
}
}
echo ("OLDarg: $argument")
echo ("newarg: $newarg")
#Set-ItemProperty -Path $regpath -Name Arguments -Value $newarg
@LoganGray
Copy link
Author

this is particularly tied to a command I'm going to send to a bunch of Win11 kiosks via Jumpcloud
the argument reading and changing... well, I went down a rabbit hole but liked what I ended up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment