function Register-CitrixVDA {
    param(
        [string]$VMName
    )
asnp citrix* -ErrorAction Stop
$AAddress = "xw1236.n-ad.n-ergie:80"
$VGETItem = "XdHyp:\Connections\VVcsa\VDI.Datacenter\CE202P.Cluster\$VMName.vm"

$VMWareID = (Get-item $VGETItem -AdminAddress $AAddress).Id
$CitrixID = (Get-BrokerMachine -AdminAddress $AAddress -MachineName "N-AD\$VMName").HostedMachineId

if ($VMWareID -ne $CitrixID) {
            Write-Host "→ ID NICHT IDENTISCH! $CitrixID" -ForegroundColor Red
            
            #Set-BrokerMachine -MachineName "N-AD\$VMName" -HostedMachineId $VMWareID
            Write-Host "→ $VMWareID wurde in Citrix gesetzt" -ForegroundColor Green
            #New-BrokerHostingPowerAction  -Action "Restart" -AdminAddress $AAddress -MachineName "N-AD\$VMName"
            Write-Host "→ $VMName wurde in Citrix neu gestartet." -ForegroundColor Green

        } else {
            Write-Host "→ VM:     $VMWareID" -ForegroundColor Green
            Write-Host "→ Citrix: $CitrixID" -ForegroundColor Green
        }
}
