You are here:   Research
  |  Login

Welcome to my blog, quickest way to find articles is usually to search for them.

Minimize
Search in All Title Contents
 
     

Deploying a reference image (VM) fully unattended

May 11 2014

During the TechEd 2014 NA preconference earlier today, I demonstrated how to deploy a VM fully unattended using a PowerShell script. A few people asked for the script being used so here it is.

Requirements, for this script to work, you need to have a MDT 2013 Lite Touch deployment share, configured for full automation.

In my environment the Bootstrap.ini looks like this:

[Settings]
Priority=Default

[Default]
DeployRoot=\\MDT01\MDTBuildLab$
UserDomain=VIAMONSTRA
UserID=MDT_BA
UserPassword=P@ssw0rd

SkipBDDWelcome=YES

The CustomSettings.ini looks like this:

[Settings]
Priority=Default

[Default]
_SMSTSORGNAME=ViaMonstra
UserDataLocation=NONE
DoCapture=YES
ComputerBackupLocation=\\MDT01\MDTBuildLab$\Captures
BackupFile=%TaskSequenceID%#"(" & day(date) & "-" & month(date) & "-" & year(date) & ")"#.wim
TaskSequenceID=REFW81X64-001
OSInstall=Y
AdminPassword=P@ssw0rd
TimeZoneName=Pacific Standard Time 
JoinWorkgroup=WORKGROUP
HideShell=YES
FinishAction=SHUTDOWN
DoNotCreateExtraPartition=YES
WSUSServer=mdt01.corp.viamonstra.com:8530
ApplyGPOPack=NO

SkipAdminPassword=YES
SkipProductKey=YES
SkipComputerName=YES
SkipDomainMembership=YES
SkipUserData=YES
SkipLocaleSelection=YES
SkipTaskSequence=YES
SkipTimeZone=YES
SkipApplications=YES
SkipBitLocker=YES
SkipSummary=YES
SkipRoles=YES
SkipCapture=YES
SkipFinalSummary=YES

Then, to automate the deployment of the virtual machine, I run this PowerShell script:

$VMLocation = "D:\VMs"
$VMISO = "C:\ISO\MDT Build Lab x64.iso"
$VMNetwork = "Internal"

# Create REF001
$VMName = "REF001"
$VMMemory = 1024MB
$VMDiskSize = 60GB
New-VM -Name $VMName -BootDevice CD -MemoryStartupBytes $VMMemory -SwitchName $VMNetwork -Path $VMLocation -NoVHD -Verbose
New-VHD -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -SizeBytes $VMDiskSize -Verbose
Add-VMHardDiskDrive -VMName $VMName -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -Verbose
Set-VMDvdDrive -VMName $VMName -Path $VMISO -Verbose
Start-VM -VMName $VMName

$VM = Get-VM -Name $VMName
while ($VM.State -ne "off")
{ 
    write-host "The VM is still running" 
    sleep 20 
}

Remove-VM -Name $VMName -Force
Remove-Item -Recurse -Force $VMLocation\$VMName

The above script assume you have copied the MDT 2013 boot media (ISO) to the C:\ISO folder, and named it “MDT Build Lab x64.iso”

Happy Deployment, Johan








Happy deployment, and thanks for reading!
/ The Deployment Research team



Ami Casto

Johan Arwidmark

Blog Archive

Minimize