Home OS Deployment Microsoft Deployent Toolkit Customising Reference Task Sequence

Customising Reference Task Sequence

2405
0
Reading Time: 6 minutes

In this blog post i will cover how to get the best performance out of your Reference Task Sequence and some useful Applications which are also worth adding to your deployment share to improve build times, patching and cleans.

Default Task Sequence – Untouched

Improving Performance

What I’ve found over the years of Building and Deploying through MDT, is that by default the power plan set on the device is always balanced, which is fine for general day to day use however when your wanting to get an image deployed as soon as possible and maximise all the CPU Cores on the processor. it does actually save time in deployment and image capture. So we negate this small problem we can create a ‘Run Command Line’ Module with a CMD line of :

PowerCfg.exe /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

The Actual ‘Run Command Line’ Module would look like this

Where to add the Power Plan Module? I normally add it under
1) ‘Initialization Folder‘ after the ‘Gather local only’

2) ‘State Restore’ after the ‘Gather local only’

3) ‘Imaging‘ > ‘Capture Image‘ > ‘after the reboot option’

Installing Visual Studio Runtimes (VC++)


Mikael Nystrom (TrueSec Deployment Guru) created a blog post back in 2014 (Link Here) Which allowed for the latest visual studio run times to be installed into a reference image from a single VBSScript. To save time and automate the process I’ve create a PowerShell Script which will download the VC++ Setup files and import them directly into the MDT Reference Share.

# Create Application - Action-VisualStudioRuntime
# Script Created by Mikael Nystrom 
# Source : https://deploymentbunny.com/2014/09/25/nice-to-havevb-script-wrapper-for-all-vc-installers-to-be-used-in-mdt/
# Steps  C:\Setup\Files\Tools\Get-AllC++Runtimes\Get-Downloads.ps1 -DownloadFile C:\Setup\Files\Tools\Get-AllC++Runtimes\download.xml -DownloadFolder 'C:\Setup\DL'

# Import PowerShell Modules
Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
Import-Module BitsTransfer

# Clear Screen
Clear-Host

$MDTReferenceShare = Read-Host 'Please Enter Reference Share ROOT Location (D:\ReferenceShare)'
$TmpDownload = 'C:\MDTDownload'
If (!(Test-Path $TmpDownload)) {
    New-Item -ItemType 'Directory' -Path $TmpDownload | Out-Null
    Write-Output 'Temporary Download Folder Created: C:\MDTDownload'

    # Download Visual Studio Setup Files
    Invoke-WebRequest -Uri https://raw.githubusercontent.com/DeploymentBunny/Files/master/Tools/Get-AllC%2B%2BRuntimes/Get-Downloads.ps1 -OutFile $TmpDownload\Get-Downloads.ps1
    Invoke-WebRequest -Uri https://raw.githubusercontent.com/DeploymentBunny/Files/master/Tools/Get-AllC%2B%2BRuntimes/download.xml -OutFile $TmpDownload\download.xml
    Invoke-Expression -Command "$TmpDownload\Get-Downloads.ps1 -DownloadFile $TmpDownload\download.xml $TmpDownload\Sources"
    Write-Output `r 'Visual Studio Runtime Setup Files Downloaded' `r
}

# Import Visual Studio Application
New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "$MDTReferenceShare" | Out-Null
Invoke-WebRequest -Uri https://github.com/DeploymentBunny/Files/blob/master/Tools/Install-X86-X64-C%2B%2B/Install-MicrosoftVisualC%2B%2Bx86x64.wsf  -OutFile $TmpDownload\Install-VisualStudioRuntimes.wsf -Verbose
import-MDTApplication -path "DS001:\Applications" -enable "True" -Name "DeploymentBunny - Visual Studio ++" -ShortName "VisualStudio++" -Version "" -Publisher "Mikael Nystrom (DeploymentBunny)" -Language "" -CommandLine "cscript.exe Action-Install-VisualStudioRuntimes.wsf" -WorkingDirectory ".\Applications\DeploymentBunny - Visual Studio" -ApplicationSourcePath "$TmpDownload" -DestinationFolder "DeploymentBunny - Visual Studio" -Verbose
Write-Output `r 'MDT Application Import Complete' `r
Remove-Item $TmpDownload -Force -Recurse -Verbose ; Remove-PSDrive 'DS001'

The Visual Studio Runtime Script can be added in at any stage on the ‘State Restore‘ – Personally i usually root folder before the Windows Update Tasks called ‘Pre-WU Tasks‘ then a Sub Folder call ‘Core Applications’ and add the VC++ and Latest .Net Frameworks and Microsoft Silverlight.

De-Bloating Windows 10

GitHub User: Sycnex has created a set of PowerShell Scripts to help with removing the default Windows 10 Metro/Modern Applications which come pre-installed with the VL Media direct from Microsoft.

The script we are going to be looking into for this blog post will be the ‘Windows10SysPrepDebloater.ps1‘ Using the below code we can download the latest Windows10SysprepDebloater.ps1

# Download Windows10Debloter Script
# Source : https://github.com/Sycnex/Windows10Debloater

# Clear Screen
Clear-Host

# Define Variables
$MDTReferenceShare = Read-Host 'Please Enter Reference Share ROOT Location (D:\ReferenceShare)'

# Download PowerShell Script
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Sycnex/Windows10Debloater/master/Windows10SysPrepDebloater.ps1 -OutFile $MDTReferenceShare\Scripts\Windows10SysPrepDebloater.ps1
Write-Output 'Windows10SysPrepDebloater Downloaded'

Editing the Windows10SysPrepDebloater Script
From File Explorer navigate to the location of the script. (D:\ReferenceShare\Scripts\Windows10SysPrepDebloater.ps1)
Open the Script using the PowerShell ISE

The Out of the Box Default ‘White-listed (Applications to be kept) are:

'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|  Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint|Microsoft.WindowsCamera|.NET|Framework|Microsoft.HEIFImageExtension|Microsoft.ScreenSketch|Microsoft.StorePurchaseApp|    Microsoft.VP9VideoExtensions|Microsoft.WebMediaExtensions|Microsoft.WebpImageExtension|Microsoft.DesktopAppInstaller'

You can edit the above White-list with the AppxPackage ID’s from the list below – Remember adding the below to the white-list will keep them in the Reference Image.

Windows 10 1809 AppxPackage List

Microsoft.AAD.BrokerPlugin
Microsoft.Windows.CloudExperienceHost
Microsoft.Windows.ShellExperienceHost
windows.immersivecontrolpanel
Microsoft.Windows.Cortana
Microsoft.MicrosoftEdge
Microsoft.Windows.ContentDeliveryManager
Microsoft.NET.Native.Runtime.1.7
Microsoft.NET.Native.Runtime.1.7
Windows.PrintDialog
Microsoft.XboxGameCallableUI
Microsoft.Windows.SecureAssessmentBrowser
Windows.CBSPreview
Microsoft.Windows.XGpuEjectDialog
Microsoft.Windows.SecHealthUI
Microsoft.Windows.PinningConfirmationDialog
Microsoft.Windows.PeopleExperienceHost
Microsoft.Windows.ParentalControls
Microsoft.Windows.OOBENetworkConnectionFlow
Microsoft.Windows.OOBENetworkCaptivePortal
Microsoft.PPIProjection
Microsoft.Windows.Apprep.ChxApp
Microsoft.Windows.CapturePicker
Microsoft.Windows.NarratorQuickStart
Microsoft.Win32WebViewHost
Microsoft.LockApp
Microsoft.AsyncTextService
InputApp
Microsoft.AccountsControl
Microsoft.Windows.AssignedAccessLockApp
Microsoft.ECApp
Microsoft.CredDialogHost
Microsoft.BioEnrollment
Microsoft.Wallet
Microsoft.WebpImageExtension
Microsoft.Xbox.TCUI
Microsoft.UI.Xaml.2.0
Microsoft.UI.Xaml.2.0
Microsoft.XboxSpeechToTextOverlay
Microsoft.MixedReality.Portal
Microsoft.Advertising.Xaml
Microsoft.Advertising.Xaml
Microsoft.Services.Store.Engagement
Microsoft.Services.Store.Engagement
Microsoft.StorePurchaseApp
Microsoft.BingWeather
Microsoft.MicrosoftEdgeDevToolsClient
Microsoft.NET.Native.Framework.1.7
Microsoft.NET.Native.Framework.1.7
Microsoft.VCLibs.140.00
Microsoft.VCLibs.140.00
Microsoft.GetHelp
Microsoft.NET.Native.Runtime.2.2
Microsoft.NET.Native.Runtime.2.2
Microsoft.NET.Native.Framework.2.2
Microsoft.NET.Native.Framework.2.2
Microsoft.Microsoft3DViewer
Microsoft.MSPaint
Microsoft.WindowsMaps
Microsoft.WindowsSoundRecorder
Microsoft.HEIFImageExtension
Microsoft.ZuneMusic
Microsoft.ScreenSketch
Microsoft.People
Microsoft.WindowsAlarms
Microsoft.MicrosoftOfficeHub
Microsoft.WindowsFeedbackHub
Microsoft.Print3D
Microsoft.ZuneVideo
Microsoft.WebMediaExtensions
Microsoft.WindowsCamera
Microsoft.MicrosoftSolitaireCollection
Microsoft.VCLibs.140.00.UWPDesktop
Microsoft.VCLibs.140.00.UWPDesktop
Microsoft.XboxGamingOverlay
Microsoft.VP9VideoExtensions
Microsoft.DesktopAppInstaller
Microsoft.Office.OneNote
Microsoft.Getstarted
microsoft.windowscommunicationsapps
Microsoft.WindowsStore
Microsoft.XboxApp
Microsoft.OneConnect
Microsoft.Windows.Photos
Microsoft.XboxGameOverlay
Microsoft.UI.Xaml.2.1
Microsoft.UI.Xaml.2.1
Microsoft.YourPhone
Microsoft.WindowsCalculator
Microsoft.Messaging
Microsoft.SkypeApp
Microsoft.MicrosoftStickyNotes
Microsoft.XboxIdentityProvider

Adding Windows10SysPrepDebloater into the Reference Task Sequence

This Script again can do anywhere within the ‘State Restore‘. Personally, I prefer to add the script before the Windows Update Modules run. As the De-bloater script will disable the store updates for the modern apps which have been removed. to add the Script into the Task Sequence we can use a ‘Run PowerShell Script’ Module and add the following into it:

%SCRIPTROOT%\Windows10SysPrepDebloater.ps1

Deploying CleanupBeforeSysprep Script

Another Script from Mikael Nystrom (TrueSec Deployment Guru) this script is to be run at the end of the deployment task just before the Sysprep Process runs. This resets various windows features and runs a disk cleanup over. Below is the simple PowerShell Import Script I’ve created to help save time.

# Create Application - Action-CleanupBeforeSysprep
# Script Created by Mikael Nystrom 
# Source : https://deploymentbunny.com/2014/06/05/nice-to-know-get-rid-of-all-junk-before-sysprep-and-capture-when-creating-a-reference-image-in-mdt/
# Steps  : Download and  Import Action-CleanupBeforeSysprep

# Import PowerShell Modules
Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
Import-Module BitsTransfer

# Clear Screen
Clear-Host
$MDTReferenceShare = Read-Host 'Please Enter Reference Share ROOT Location (D:\ReferenceShare)'
$TmpDownload = 'C:\MDTDownload'
If (!(Test-Path $TmpDownload)) {
    New-Item -ItemType 'Directory' -Path $TmpDownload | Out-Null
    Write-Output 'Temporary Download Folder Created: C:\MDTDownload'

    # Download Action-CleanupBeforeSysprep
    Invoke-WebRequest -Uri https://github.com/DeploymentBunny/Files/blob/master/Tools/Action-CleanupBeforeSysprep/Action-CleanupBeforeSysprep.wsf  -OutFile $TmpDownload\Action-CleanupBeforeSysprep.wsf -Verbose
    Write-Output `r 'Action-CleanupBeforeSysprep.wsf Downloaded' `r
}

# Import Cleanup Before Sstem
New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "$MDTReferenceShare" | Out-Null
import-MDTApplication -path "DS001:\Applications" -enable "True" -Name "DeploymentBunny - CleanupBeforeSysprep" -ShortName "CleanupBeforeSysprep" -Version "" -Publisher "Mikael Nystrom (DeploymentBunny)" -Language "" -CommandLine "cscript.exe Action-CleanupBeforeSysprep.wsf" -WorkingDirectory ".\Applications\DeploymentBunny - CleanupBeforeSysprep" -ApplicationSourcePath "$TmpDownload" -DestinationFolder "DeploymentBunny - CleanupBeforeSysprep" -Verbose
Write-Output `r 'MDT Application Import Complete' `r
Remove-Item $TmpDownload -Force -Recurse -Verbose ; Remove-PSDrive 'DS001'

Adding CleanupBeforeSysprep into the Reference Task Sequence

Mikael Recommends that you complete a Reboot of the Operating System before running this script to ensure that there are no pending reboots, or update processes running. Depending on the specs of the Virtual Machine this is running on, I’ve seen this take up to 2 Hours, this is mainly on the Disk Cleanup and Windows Update Patch cleanups.

Useful Blog Posts on Creating Reference Builds

Mikael Nystrom – Twitter
Johan Ardwick – Twitter
Michael Niehaus – Twitter
Official Microsoft TechNet Reference Build Guide
DeploymentResearch – Building 1809 Reference Image
DeploymentBunny – Visual Studio Run Time (VC++)
DeploymenBunny – CleanupBeforeSysprep

LEAVE A REPLY

Please enter your comment!
Please enter your name here