In case you’re using Microsoft’s awesome Microsoft Deployment Toolkit [MDT] solution, there might be a thing you don’t often do, but can take up a while of your time and can have quite some impact if you forget a few steps..
What I’m talking about is updating/regenerating your MDT Boot Images and replacing them within Windows Deployment Services [WDS].
Of course such a thing is ideally done through PowerShell as it automates and thus limits the amount of human errors possible.
An important thing in the script is currently ‘missing’ as it’s currently placed within my $profile on my MDT server, so I’ll also provide you this, as it’s important for actual usage:
1
2
3
4
|
Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
$MdtDrive = 'MDT'
$MdtRoot = 'E:\MDTShare'
$null = New-PSDrive -Name $MdtDrive -PSProvider MDTProvider -Root $MdtRoot
|
It’s rather simple, but required in order to gain access to any of the MDT related PowerShell cmdlets.
Since I’ll use it for more than just this script, I’ve placed it within my profile.
Now it’s not ideal and I’m sure June Blender will have a word with me on my [currently] lacking help notes, I thought I’d share it anyways 😉
I’ll delve more into techniques used in the script in another post, but there’s a new trick or 2 that I’ve not yet discussed on my blog before which might be interesting to browse through.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#requires -RunAsAdministrator
[cmdletbinding()]
param(
[Parameter(Position=0)]
[ValidateSet('x86','x64','Both')]
$Architectures = 'Both'
)
if ($Architectures -eq 'Both'){
$Architectures = 'x86','x64'
}
$ImgName = 'MDT Boot Image '
$ImgPath = 'LiteTouchPE_'
Write-Verbose 'Updating MDT Deployment share, completely regenerating boot images.'
Write-Verbose 'Sit back, this could take a while!'
#Update-MDTDeploymentShare -Path "$($MdtDrive):" -Force -Verbose
foreach ($Architecture in $Architectures) {
$BootPath = "$MdtRoot\Boot\$($ImgPath)$Architecture.wim"
$BootName = "$ImgName($Architecture)"
Write-Verbose "Boot images file path is '$BootPath'"
Write-Verbose "Boot image name is '$BootName'"
if (Get-WdsBootImage -Architecture $Architecture -ImageName $BootName) {
try {
Write-Verbose "Removing boot image '$BootName'"
Remove-WdsBootImage -Architecture $Architecture -ImageName $BootName -ErrorAction Stop
Write-Verbose "Importing boot image '$BootName'"
Import-WdsBootImage -Path $BootPath -NewImageName $BootName -SkipVerify
} catch {
Write-Warning "Unable to remove WDS Boot image '$BootName'. $($_.Exception.Message)"
}
} else {
Write-Verbose "Importing boot image '$BootName'"
Import-WdsBootImage -Path $BootPath -NewImageName $BootName -SkipVerify
}
}
|