$domain = 'cascades.local'
$srv = 'CS-SERVER'
$sysvol = "\\$srv\SYSVOL\$domain\Policies"

$gpo = Get-GPO -Name 'CSC - Folder Redirection' -Domain $domain
$guid = "{$($gpo.Id.ToString().ToUpper())}"
$xmlPath = "$sysvol\$guid\User\Preferences\Registry\Registry.xml"

$bytes = [System.IO.File]::ReadAllBytes($xmlPath)
Write-Output "REGXML_B64_START"
Write-Output ([Convert]::ToBase64String($bytes))
Write-Output "REGXML_B64_END"

# Also get LE GPO GPC attributes from AD
Import-Module ActiveDirectory -EA SilentlyContinue
$leGpo = Get-GPO -Name 'CSC - Folder Redirection (LE)' -Domain $domain
$leGuid = $leGpo.Id.ToString().ToUpper()
$gpcObj = Get-ADObject -Filter "Name -eq '{$leGuid}'" `
    -SearchBase "CN=Policies,CN=System,DC=cascades,DC=local" `
    -Properties gPCUserExtensionNames,gPCMachineExtensionNames,versionNumber -EA SilentlyContinue
Write-Output "LEGPO_EXT: $($gpcObj.gPCUserExtensionNames)"
