Constrained delegation for Hyper-V live migration and SCVMM library ISO sharing

When you have a lot of Hyper-V servers managing the constrained delegation required to enable remotely initiated Live Migration is a real pain. I wrote a little PowerShell script which does it for me, including the CIFS delegation for sharing ISO files to VMs from the SCVMM library share.

Fill in your own variables where needed, run on a schedule and you’re fine, never to worry about KCD again! (For this script I assume there is some sort of naming convention on which the Hyper-V servers and clusters are recognizable, when this is not the case, you can of course utilize other sources like SCVMM to acquire the right computer names)

$DNSSuffix = "." + (Get-ADDomain).dnsroot
$computers = Get-ADComputer -Filter 'name -like "HYP*" -and name -notlike "HYPCLUS*"'
foreach ($c in $computers)
    $kcdentries = $computers | ?{$ -ne $}
    [array]$ServiceString = @()
    foreach ($k in $kcdentries)
        $ServiceString += "cifs/"+$$DNSSuffix
        $ServiceString += "cifs/"+$
        $ServiceString += "Microsoft Virtual System Migration Service/"+$$DNSSuffix
        $ServiceString += "Microsoft Virtual System Migration Service/"+$
    $ServiceString += "cifs/"+$SCVMMLibrarySRV+$DNSSuffix
    $ServiceString += "cifs/"+$SCVMMLibrarySRV
    <# for LM KCD with Kerberos only is enough ISO sharing through SCVMM library requires protocol transition according to to enable protocol transition, the useraccountcontrol attribute will be changed to 16781344 #>
    Set-ADObject -Identity $C -replace @{"msDS-AllowedToDelegateTo" = $ServiceString; "userAccountControl"="16781344"}
comments powered by Disqus