title: How to run a script on a new Hyper-V Windows VMM virtual machine
body: <p>I use a <a href="https://gist.github.com/grenade/10152444#file-new-vm-ps1" rel="nofollow">powershell script</a>, triggered by teamcity, to spin up new Windows Server VMs. Currently, when the machine is up and running, I need to log in via the VMM console to make a couple of configuration changes (enable file sharing, network discovery, msdeploy and remoting over winrm) in order to allow other teamcity jobs to be able to deploy enterprise apps to the VM.</p>
  
  <p>I haven't found any way to run my config setup scripts on the new VM other than by using the GUI console in VMM. For <a href="http://technet.microsoft.com/en-us/library/hh801699.aspx" rel="nofollow">VMHosts</a>, there is <a href="http://technet.microsoft.com/en-us/library/hh801727.aspx" rel="nofollow">Invoke-SCScriptCommand</a>, but this doesn't work for <a href="http://technet.microsoft.com/en-us/library/hh801556.aspx" rel="nofollow">virtual machines</a> themselves. Am I missing something or do I have to alter the template that my VM's are built from, in order to get the required config on the VMs?</p>