Skip to content

Instantly share code, notes, and snippets.

@b-long
Created February 14, 2017 21:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-long/1dd155ba89f4b83a42485ddc10327683 to your computer and use it in GitHub Desktop.
Save b-long/1dd155ba89f4b83a42485ddc10327683 to your computer and use it in GitHub Desktop.
CloudForms Sysprep example - Windows Server 2008 R2
<%
# Setting Variables
debug = false
ms_product_key = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
locale = "en-US"
registered_organization = "My Company"
registered_owner = "My Company"
# Change values if blank
evm[:hostname] = evm[:vm_target_hostname] if evm[:hostname].blank? # Use vm_target_hostname if hostname in the dialog was blank
evm[:addr_mode] = ['dhcp'] if evm[:ip_addr].blank? || evm[:subnet_mask].blank? || evm[:gateway].blank?
%>
<%= evm.inspect if debug == true %>
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component name="Microsoft-Windows-OutOfBoxExperience" 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">
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
</component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" 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">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" 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">
<InputLocale><%= locale %></InputLocale>
<SystemLocale><%= locale %></SystemLocale>
<UserLocale><%= locale %></UserLocale>
<UILanguage><%= locale %></UILanguage>
</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>
<NetworkLocation>Work</NetworkLocation>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value><%= MiqPassword.sysprep_crypt(evm[:root_password]) %></Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
<RegisteredOrganization><%= registered_organization %></RegisteredOrganization>
<RegisteredOwner><%= registered_owner %></RegisteredOwner>
</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">
<ProductKey><%= ms_product_key %></ProductKey>
<% unless evm[:hostname].blank? %>
<ComputerName><%= evm[:hostname] %></ComputerName>
<% end %>
</component>
<% if evm[:addr_mode].first == 'static' %>
<component name="Microsoft-Windows-DNS-Client" 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">
<Interfaces>
<Interface wcm:action="add">
<DNSServerSearchOrder>
<IpAddress wcm:action="add" wcm:keyValue="1"><%= evm[:dns_servers].split(" ").first %></IpAddress>
</DNSServerSearchOrder>
<Identifier>Local Area Connection</Identifier>
<EnableAdapterDomainNameRegistration>true</EnableAdapterDomainNameRegistration>
<DisableDynamicUpdate>false</DisableDynamicUpdate>
<DNSDomain><%= evm[:dns_suffixes].split(" ").first %></DNSDomain>
</Interface>
</Interfaces>
<DNSDomain><%= evm[:dns_suffixes].split(" ").first %></DNSDomain>
<UseDomainNameDevolution>true</UseDomainNameDevolution>
</component>
<component name="Microsoft-Windows-TCPIP" 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">
<Interfaces>
<Interface wcm:action="add">
<Identifier>Local Area Connection</Identifier>
<Ipv4Settings>
<DhcpEnabled>false</DhcpEnabled>
<Metric>10</Metric>
<RouterDiscoveryEnabled>false</RouterDiscoveryEnabled>
</Ipv4Settings>
<UnicastIpAddresses>
<IpAddress wcm:action="add" wcm:keyValue="1"><%= evm[:ip_addr] %>/<%= evm[:cidr] %></IpAddress>
</UnicastIpAddresses>
<Routes>
<Route wcm:action="add">
<Identifier>1</Identifier>
<Metric>10</Metric>
<NextHopAddress><%= evm[:gateway] %></NextHopAddress>
<Prefix>0.0.0.0/0</Prefix>
</Route>
</Routes>
</Interface>
</Interfaces>
</component>
<% end %>
</settings>
<cpi:offlineImage cpi:source="catalog://path/to/microsoft/2k8media/sources/install_windows server 2008 r2 serverenterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment