Import-Module GroupPolicy
Import-Module ActiveDirectory
$guid = '3B5CD9A6-A278-4676-A9FD-9396D21A8261'
# GP Preferences CSE GUIDs for Shortcuts
$cse = '[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{0F6B957D-509E-11D1-A7CC-0000F87571E3}]'
# Update AD object
$dn = "CN={$guid},CN=Policies,CN=System,DC=cascades,DC=local"
Set-ADObject $dn -Replace @{gPCUserExtensionNames=$cse}
Write-Output "AD gPCUserExtensionNames set: $cse"
# Update GPT.INI
$gptPath = "\\cascades.local\SYSVOL\cascades.local\Policies\{$guid}\GPT.INI"
$ini = Get-Content $gptPath -Raw
if ($ini -match 'Version=(\d+)') {
    $ver = [int]$matches[1]; $newVer = ((($ver -shr 16)+1) -shl 16) -bor ($ver -band 0xFFFF)
    $newIni = "[General]`r`nVersion=$newVer`r`ndisplayName=New Group Policy Object`r`ngPCUserExtensionNames=$cse`r`n"
    Set-Content $gptPath $newIni -Force
    Write-Output "GPT.INI updated, version $ver -> $newVer"
}
# Verify
$obj = Get-ADObject $dn -Properties gPCUserExtensionNames
Write-Output "Verify AD: $($obj.gPCUserExtensionNames)"
Write-Output (Get-Content $gptPath -Raw)
