Virtual Machine Manager: Deploy virtual machines with windows features RRS feed

  • Question

  • Hi everybody,

    first of all I hope this is the right subforum. :) EDIT: No its not, thanks to any Mod for moving this post into the right forum :)

    I have a Windows Server 2019 environment with virtual machine manager and hyper-v, where I aim to deploy ready-to-use virtual machines with windows roles like "Domaincontroller" or terminal server".


    I've made some research and found some ways to realize this. The first one is the use of service templates. Does anybody have a good guide to install that? The GUI isn't very user-friendly in my eyes and I have not found a good guide yet.

    At the moment my idea is to use an Answer File or the RunOnce Commands in the properties of the virtual machine templates.

    I've tested the RunOnce Commands and they work fine, I've used these commands:

    powershell Install-WindowsFeature AD-Domain-Services
    powershell Install-ADDSForest -CreateDnsDelegation:$false  -DomainName -DomainNetbiosName domain -InstallDns -Force -SafeModeAdministratorPassword $(convertto-securestring -string "Test123!" -asplaintext -force)

    This works, the only downside is, that a User has to login to the VM to initially start this process.

    I've tested some thing with the unattended answer file. My idea was to deliver the commands with the help of the "specialize" configuration pass via RunSynchronousCommand. 

    When I'm testing this and look into the virtual machine via console, I see a powershell window being opened, but the commands don't seem to work. I see a "Critical Error" message for a part of a second. There must be something wrong with using "Install-WindowsFeature" in the "specialize" configuration pass, because a test with the cmdlet "New-Item" did work without problems.

    I also tried using the Microsoft-Windows-Foundation-Package and enable the windows-role which I need via windows system image manager, but that didn't have any effect.

    This is how my answer file looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
            <package action="install">
                <assemblyIdentity name="Microsoft-Windows-Foundation-Package" version="10.0.17763.1" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" />
                <selection name="DNS-Server-Full-Role" state="false" />
                <selection name="DirectoryServices-DomainController" state="true" />
        <settings pass="specialize">
            <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="" xmlns:xsi="">
                    <RunSynchronousCommand wcm:action="add">
                        <Path>powershell Install-WindowsFeature AD-Domain-Services</Path>
    		<RunSynchronousCommand wcm:action="add">
                        <Path>powershell powershell Install-ADDSForest -CreateDnsDelegation:$false -DomainName -DomainNetbiosName temp -InstallDns -Force -SafeModeAdministratorPassword $(convertto-securestring -string "Test123!" -asplaintext -force)</Path>
        <cpi:offlineImage cpi:source="catalog:c:/temp/windows files 2/sources/install_windows server 2019 serverstandard.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />

    Does anybody have experiences with that?

    Best greetings

    • Edited by xNitro99 Sunday, October 25, 2020 5:59 PM
    Sunday, October 25, 2020 4:50 PM

All replies