SCVMM 2012 R2 及應答文件BUG解決

背景:windows

1. 計劃使用SCVMM 2012 R2自動部署win7 虛擬機模板,VM模板雖然已經使用過不少次,可是客戶端版的OS和服務器端的OS版有一點不同,那就是客戶端版的操做系統會默認禁用administrator 帳號,而後必須新建一個管理員帳號。服務器

2. 計劃使用SCVMM VM 模板中的應答文件來用Unattend.xml 來默認啓用一些設置(如防火牆默認開通遠程桌面,開啓默認管理員並設置密碼),自動登陸一次默認管理員,而後執行一些命令,如配置啓動菜單(VM崩潰時好像會進入恢復模式,這樣VM重啓時須要人工介入),其餘配置一些服務之類的操做。ide

 

問題: SCVMM 裏這個Win7的指定管理員帳號時,不能使用administrator ,不然部署時會報錯(10619,所提供的用戶名不是有效的該操做系統的本地管理員名稱)。測試

當你配置其餘的帳號名稱時,SCVMM在unattend.xml 中生成一段OOBE階段的建立本地帳號的設置,若是使用administrator 那麼會和現有的administrator 衝突吧(可是奇怪的是我在對server VM 的模板上都是這樣用的,只有client 版本的有這樣的問題)。加密

image

問題2:因爲問題1 ,那麼我這裏創建的admin的帳號,我但願在VM部署後自動被刪掉。上圖的GUIRunonce的部分彷佛能夠作這個工做,可是問題在於GUIRunonce須要登陸一個帳號,那麼解決的話要自動登陸默認administrator帳號一次,而後執行一些默認命令如net user admin /del .操作系統

 

BUG 呈現:雖然以上想法在原理上沒有問題,並且我也拿unattend.xml 直接在hyper-v VM 測試下了下沒有問題,可是在用SCVMM時卻出了BUG。component

1. 現象1 ,若是你再unattend.xml 中配置了autologon ,並且配置了logoncount ,那麼SCVMM最後生成合並的unattend.xml中,logonCount 會變成999次,意味着你必須還要其餘手段來清除autologon,不然這個VM一直自動登陸。server

2.現象2,若是你再unattend.xml 中配置了autologon 並且同時在SCVMM 中指定了 GUIRunOnce命令,那麼這個GUIRunOnce的命令在最後合成的unattend.xml 變成空白,就算你不在SCVMM的GUIRunOnce窗口中配這些命令,而是直接寫在應答文件裏,SCVMM 最後合併時也會把這些命令給變成空的。xml

 

下面是問題XML,並且在微軟的論壇中也有人提到這個BUG,彷佛年代好久遠了,可是我最新的2012 r2 的版本仍是問題依舊。blog

https://social.technet.microsoft.com/Forums/systemcenter/en-US/de874b1b-bd93-4746-a138-22422ff3717c/unattendxml-parsingmerging-issue-with-scvmm-2012-r2?forum=virtualmachinemanager

 

e2de2327-902c-4eec-a263-8241c644cee8snip

 

思考及解決:

1. 若是是autologon 致使的BUG,那麼可否繞過這個部分,不用登陸帳號執行命令。有的,windows 部署完在第一次登陸帳號前,能夠配置一個自定義腳原本執行命令,腳本名稱固定爲setupComplete.cmd,腳本路徑在%WINDIR%\Setup\Scripts\SetupComplete.cmd, 咱們只須要建立修改這個腳本便可了。

參考:

https://technet.microsoft.com/en-us/library/cc766314(v=ws.10).aspx 

 

成品SCVMM 中用的Unattend.xml(針對32位win7),64位的win7 ,修改下processorArchitecture="x86" 中的x86 位x64,就能夠了:

備註信息:XML中的產品序列號爲KMS Client Key。默認開啓遠程桌面及遠程桌面對應的防火牆。默認啓用administrator 帳號,administrator 帳號的密碼部分是加密後的值,你能夠在windows system image manager 中來更改加密的密碼(輸入的時候明文,寫出的是加密的密文)

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="specialize">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ComputerName>*</ComputerName>
            <RegisteredOwner></RegisteredOwner>
            <ShowWindowsLive>false</ShowWindowsLive>
            <RegisteredOrganization></RegisteredOrganization>
            <ProductKey>FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4</ProductKey>
        </component>
        <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <fDenyTSConnections>false</fDenyTSConnections>
        </component>
        <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SecurityLayer>1</SecurityLayer>
            <UserAuthentication>0</UserAuthentication>
        </component>
        <component name="Networking-MPSSVC-Svc" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <FirewallGroups>
                <FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop">
                    <Active>true</Active>
                    <Group>@FirewallAPI.dll,-28752</Group>
                    <Profile>all</Profile>
                </FirewallGroup>
            </FirewallGroups>
        </component>
        <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <Identification>
                <JoinWorkgroup>WORKGROUP</JoinWorkgroup>
            </Identification>
        </component>
        <component name="Microsoft-Windows-Deployment" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Order>1</Order>
                    <Path>net user administrator /active:yes</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <ProtectYourPC>1</ProtectYourPC>
                <NetworkLocation>Work</NetworkLocation>
            </OOBE>
            <RegisteredOrganization>microsoft</RegisteredOrganization>
            <RegisteredOwner>microsoft</RegisteredOwner>
            <TimeZone>China Standard Time</TimeZone>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>Password Here ==</Value>
                    <PlainText>false</PlainText>
                </AdministratorPassword>
            </UserAccounts>
        </component>
        <component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <UserLocale>zh-CN</UserLocale>
            <UILanguageFallback></UILanguageFallback>
            <UILanguage>zh-CN</UILanguage>
            <SystemLocale>zh-CN</SystemLocale>
            <InputLocale>0804:00000804</InputLocale>
        </component>
    </settings>
</unattend>

 

成品 setupComplete.cmd:

@echo off

net user admin /del

bcdedit /set {default} recoveryenabled No

相關文章
相關標籤/搜索