Skip to content

Commit 41b6ac0

Browse files
committed
Added stuff to readme
Added unattended.xml which i use for my sysprepped-machine machines.csv & .xlsx as template for pipeline input many changes to new-labvm.ps1
1 parent 2b9fbc5 commit 41b6ac0

File tree

5 files changed

+106
-4
lines changed

5 files changed

+106
-4
lines changed

Machines.xlsx

7.87 KB
Binary file not shown.

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
11
"# spawn-vm"
2+
Create new Hyper-V machines, based on a sysprepped, ready VHD to quickly spawn multiple VMs for lab purposes, using differencing disks .
3+
Mre info on differencing disks: https://technet.microsoft.com/en-us/library/cc720381(v=ws.10).aspx
4+
5+
Summary:
6+
- Create a new hyper-v Virtual Machine with a windows client of your choice.
7+
- Load it up with the settings, software, patches you need.
8+
- Add an unattend.xml for extra automation. Check my github for mine.
9+
Tutorial to make basic unattend.xml: https://support.software.dell.com/k2000-systems-deployment-appliance/kb/154057
10+
- Run sysprep and shut the machine down
11+
- Delete the VM from your Hyper-V manager. NOT THE VHDX-file !!!
12+
- Use this VHDX file as your base for all your new lab VMs. Don't touch it again.
13+
- Use this script to create new VMs using the differencing VHDX-mechanics.

machines.csv

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VMName,Sourcepath,Memory
2+
Athos,E:\vms\Differentialclient\Differntialclient\Virtual Hard Disks\Differntialclient.vhdx,4096MB
3+
Porthos,E:\vms\Differentialclient\Differntialclient\Virtual Hard Disks\Differntialclient.vhdx,4096MB
4+
Aramis,E:\vms\Differentialclient\Differntialclient\Virtual Hard Disks\Differntialclient.vhdx,4096MB

new-labvm.ps1

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#Requires -RunAsAdministrator
2+
#Requires -Modules Hyper-v
3+
<#
4+
.Synopsis
5+
Create VMs using differencing VHDs for lab purposes
6+
.DESCRIPTION
7+
Create new Hyper-V machines, based on a sysprepped, ready VHD to quickly spawn multiple VMs for lab purposes.
8+
.EXAMPLE
9+
import-csv "machines.csv" | .\new-labvm.ps1 | start-vm
10+
Using the default CSV-template, you create the VMs and inmediatly boot them up.
11+
.EXAMPLE
12+
.\new-labvm.ps1 -VMName <string[]>
13+
.\new-labvm.ps1 -VMName bob,jef,lilly
14+
Creates 3 VM's, named bob, jef and lilly with default values
15+
#>
16+
217
[CMDLETBinding()]
318

419
param(
@@ -11,18 +26,23 @@ param(
1126
Valuefrompipeline=$true,
1227
Valuefrompipelinebypropertyname=$true
1328
)]
14-
[string[]]$Sourcepath="E:\vms\Differentialclient\Differntialclient\Virtual Hard Disks\differentialclient.vhdx"
29+
[string]$Sourcepath="E:\vms\Differentialclient\Differntialclient\Virtual Hard Disks\Differntialclient.vhdx",
30+
[Parameter(Mandatory=$false,
31+
Valuefrompipeline=$true,
32+
Valuefrompipelinebypropertyname=$true
33+
)]
34+
[string]$Memory="2048MB"
1535
)
1636

1737
BEGIN{
1838
}
1939

2040
PROCESS{
41+
2142
foreach($VM in $VMName)
2243
{
23-
new-vhd -ParentPath $SourcePath -path E:\vms\$VM.vhdx -Differencing
24-
New-VM -Name "$VM" -VHDPath "E:\vms\$VM.vhdx" -MemoryStartupBytes 2048MB
25-
Start-VM -Name "$VM"
44+
$NewVHD= new-vhd -ParentPath $SourcePath -path E:\vms\$VM.vhdx -Differencing
45+
$NewVM = New-VM -Name "$VM" -VHDPath "E:\vms\$VM.vhdx" -MemoryStartupBytes 2048MB
2646
}
2747
}
2848
END{}

unattend.xml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<unattend xmlns="urn:schemas-microsoft-com:unattend">
3+
<settings pass="generalize">
4+
<component name="Microsoft-Windows-Security-SPP" 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">
5+
<SkipRearm>1</SkipRearm>
6+
</component>
7+
</settings>
8+
<settings pass="specialize">
9+
<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">
10+
<RunSynchronous>
11+
<RunSynchronousCommand wcm:action="add">
12+
<Order>1</Order>
13+
<Path>net user administrator /active:yes</Path>
14+
</RunSynchronousCommand>
15+
</RunSynchronous>
16+
</component>
17+
<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">
18+
<CopyProfile>true</CopyProfile>
19+
<RegisteredOrganization>Microsoft</RegisteredOrganization>
20+
<RegisteredOwner>AutoBVT</RegisteredOwner>
21+
<TimeZone>Romance Standard Time</TimeZone>
22+
</component>
23+
</settings>
24+
<settings pass="oobeSystem">
25+
<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">
26+
<InputLocale>nl-BE</InputLocale>
27+
<SystemLocale>nl-BE</SystemLocale>
28+
<UILanguage>en-US</UILanguage>
29+
<UserLocale>nl-BE</UserLocale>
30+
</component>
31+
<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">
32+
<AutoLogon>
33+
<Password>
34+
<Value>Vdab1234</Value>
35+
</Password>
36+
<Enabled>true</Enabled>
37+
<LogonCount>5</LogonCount>
38+
<Username>Administrator</Username>
39+
</AutoLogon>
40+
<OOBE>
41+
<HideEULAPage>true</HideEULAPage>
42+
<NetworkLocation>Work</NetworkLocation>
43+
<ProtectYourPC>1</ProtectYourPC>
44+
</OOBE>
45+
<UserAccounts>
46+
<AdministratorPassword>
47+
<Value>Vdab1234</Value>
48+
</AdministratorPassword>
49+
<LocalAccounts>
50+
<LocalAccount wcm:action="add">
51+
<Password>
52+
<Value>Vdab1234</Value>
53+
</Password>
54+
<Description>testuser</Description>
55+
<DisplayName>Labo user</DisplayName>
56+
<Name>Labo</Name>
57+
<Group>Administrators</Group>
58+
</LocalAccount>
59+
</LocalAccounts>
60+
</UserAccounts>
61+
<RegisteredOrganization>VDAB LABO</RegisteredOrganization>
62+
<RegisteredOwner>VDAB LAB user</RegisteredOwner>
63+
</component>
64+
</settings>
65+
<cpi:offlineImage cpi:source="catalog://wds/deploymentshare$/operating systems/windows 8.1 pro x64/sources/install_windows 8.1 pro.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
66+
</unattend>

0 commit comments

Comments
 (0)