Sorry I haven’t posted in a while. A case of pneumonia and Kylie had bronchitis so I’m a bit behind.

Here is an interesting bit:
I grabbed some code from and added it to some code scraped out of SCVMM to get something to automate adding a host to SCVMM.

I used Set-myCredential.ps1 to save a credential file:

$user = <span class="code-quote">"xendesktop\administrator"</span>
$file = <span class="code-quote">"c:\scripts\credentials.enc.xml"</span>
$Credential = Get-Credential
$credential.Password | ConvertFrom-SecureString | Set-Content $File

I use the reverse to get the credential and add the host to SCVMM. The idea here is to have an easy way to import a machine running the SCVMM console and add the local host. A renewable or transportable demo or test system or part of an automation script for a cloud based host. You might set up the internal networks to be identical on each physical host and then use the ip address to access the local host.

$user = <span class="code-quote">"xendesktop\administrator"</span>
$file = <span class="code-quote">"c:\scripts\credentials.enc.xml"</span>
$password = Get-Content $File | ConvertTo-SecureString
$credential = New-<span class="code-object">Object</span> <span class="code-object">System</span>.Management.Automation.PsCredential($user,$password)

$VMHostGroup = Get-VMHostGroup -VMMServer localhost | where {$_.Path -eq <span class="code-quote">"All Hosts"</span>}

Add-VMHost -VMMServer localhost -ComputerName <span class="code-quote">""</span> -Description <span class="code-quote">"" -Credential $Credential -RemoteConnectEnabled $<span class="code-keyword">true</span> -VmPaths "</span>" -Reassociate $<span class="code-keyword">false</span> -RunAsynchronously -VMHostGroup $VMHostGroup

A cool side effect is that if you do this and the host does not have Hyper-V role it will add it automatically and reboot. Cool or not cool depending on if you expect it.

Thanks for your time, and thanks for hanging out with me here.
Take care,

Crosspost Powershell to add the Host to SCVMM from your XenDesktop DDC