对于Windows Server 2008 R2 Enterprise,我有以下unattend.xml文件。
<?xml version="1.0" encoding="UTF-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:ms="urn:schemas-microsoft-com:asm.v3" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> <settings pass="windowsPE"> <component name="Microsoft-Windows-PnpCustomizationsWinPE" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64"> <DriverPaths> <PathAndCredentials wcm:action="add" wcm:keyValue="1"> <Path>C:\Windows\Temp\virtio</Path> </PathAndCredentials> </DriverPaths> </component> <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SetupUILanguage> <UILanguage>en-US</UILanguage> </SetupUILanguage> <SystemLocale>en-US</SystemLocale> <UILanguage>en-US</UILanguage> <UserLocale>en-US</UserLocale> <UILanguageFallback>en-US</UILanguageFallback> <UserLocale>en-US</UserLocale> </component> <component name="Microsoft-Windows-Setup" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64"> <DiskConfiguration> <WillShowUI>OnError</WillShowUI> <Disk wcm:action="add"> <DiskID>0</DiskID> <WillWipeDisk>true</WillWipeDisk> <CreatePartitions> <CreatePartition wcm:action="add"> <Order>1</Order> <Extend>true</Extend> <Type>Primary</Type> </CreatePartition> </CreatePartitions> <ModifyPartitions> <ModifyPartition wcm:action="add"> <Format>NTFS</Format> <Order>1</Order> <PartitionID>1</PartitionID> <Label>System</Label> </ModifyPartition> </ModifyPartitions> </Disk> </DiskConfiguration> <ImageInstall> <OSImage> <WillShowUI>Never</WillShowUI> <InstallFrom> <MetaData> <Key>/IMAGE/Name</Key> <Value>Windows Server 2008 R2 ENTERPRISE</Value> </MetaData> </InstallFrom> <InstallTo> <DiskID>0</DiskID> <PartitionID>1</PartitionID> </InstallTo> </OSImage> </ImageInstall> <UserData> <AcceptEula>true</AcceptEula> </UserData> </component> </settings> <settings pass="specialize"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ShowWindowsLive>false</ShowWindowsLive> <TimeZone>India Standard Time</TimeZone> </component> <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" 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="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UserAuthentication>0</UserAuthentication> </component> <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" 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> <Profile>all</Profile> <Group>@FirewallAPI.dll,-28752</Group> </FirewallGroup> </FirewallGroups> </component> </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" 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> <!--- Firewall to add IMCP --> <RunSynchronousCommand wcm:action="add"> <Order>1</Order> <Path>netsh advfirewall firewall add rule name=ICMP protocol=icmpv4 dir=in action=allow</Path> <Description>Add ICMP rule to enable ping on VM</Description> </RunSynchronousCommand> <!--- Command to enable cloudbase-init --> <RunSynchronousCommand wcm:action="add"> <Order>2</Order> <Path>sc config cloudbase-init start= auto</Path> <Description>Re-enable auto start of cloudbase-init</Description> <WillReboot>Never</WillReboot> </RunSynchronousCommand> </RunSynchronous> </component> <component name="Microsoft-Windows-International-Core" language="neutral" versionScope="nonSxS" publicKeyToken="31bf3856ad364e35" processorArchitecture="amd64" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> <InputLocale>en-US</InputLocale> <SystemLocale>en-US</SystemLocale> <UILanguage>en-US</UILanguage> <UserLocale>en-US</UserLocale> <UILanguageFallback>en-US</UILanguageFallback> </component> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" 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> </OOBE> <TimeZone>Coordinated Universal Time</TimeZone> <UserAccounts> <AdministratorPassword> <Value>randompass</Value> <PlainText>true</PlainText> </AdministratorPassword> </UserAccounts> <!-- Auto logon is commented out --> <!-- <AutoLogon> <Password> <Value>randompass</Value> <PlainText>true</PlainText> </Password> <Enabled>true</Enabled> <LogonCount>50</LogonCount> <Username>Administrator</Username> </AutoLogon> --> </component> </settings> </unattend>
我面临的问题是它有一个cloud-init-base服务。 如果该服务是自动启动的,那么当机器重新启动或引导到不同的机器时,它会干扰sysprep进程。 所以,为了完成sysprep,我已经在原始图像中禁用了这项服务。
现在,问题是,一旦sysprep完成,机器启动, cloud-init-base服务仍然被禁用。
相同的文件在Windows Server 2012 R2上运行。 但是,相同的XML构造在Windows Server 2008 R2上不起作用。 在oobe阶段运行命令或在sysprep完成后启用服务的方式是什么?
您需要在计算机重启后添加一个自动步骤来启用该服务。 SCCM中的任务序列中的另一个步骤,或运行一个脚本以完成构build的“运行一次”registry调用。 无论哪种方式,任务序列(如果您使用的是SCCM)或者“一次运行”调用的脚本中的几个PowerShell命令( Set-Service和Start-Service )都应该有效。