24
Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

Embed Size (px)

Citation preview

Page 1: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Customizing your Windows Deployments

Tips, Tricks and Code

Keith [email protected]

Page 2: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Agenda

•Welcome• All About Customizations• Customizing the Task Sequence• Customizing with Code• Cmd.exe, VBScript, Powershell, C#, C++ and more!

• Customizing your MDT LTI and SCCM ZTI environments!• With Hydration!

• Questions / Discussions and more!

Page 3: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Customization Step Zero

•Why Customize (why not)?• Stick with Well-Known and Proven Solutions (Aaron Margosis)

• Be careful when modifying existing code.• Use revision control.• Don’t make changes to your production environment. Test First!

• Are you using a Hacks? or Proven technologies.• CopyProfile=True (Imperfect solution, use GPO)

• Tip: KISS – Keep It Simple Stupid!• Customization – When the default just won’t do!

Page 4: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Customizing Windows with Unattend.xml• Quick and Dirty deployments • Automated Settings through Unattend.xml ComputerName=*• For Manual let the OS go through OOBE Setup.

• Best when image is “Ready to Go!”• Applications, Settings, and Drivers pre-installed.• Not recommended for heavy customizations.

• Place Unattend.xml into OS for detection.• Tip: Be aware of where your steps go in Unattend.xml…

Page 5: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Windows Configuration PassesConfiguration PassWindowsPE Run during WinPEOfflineServicing Run OfflineSpecialize Apply System Specific InfoGeneralize Run during SysprepAuditSystem Audit Mode (System)AuditUser Audit Mode (User)OOBESystem Customize the machine

Page 6: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo Unattend.xml

• All about Unattend.xml•Where instructions go.• CopyProfile Specialize• PersistAllDeviceInstalls Generalize

• Code: Create a Bootable VHD

Page 7: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

MDT and SCCM

•When to use MDT/SCCM?• Don’t create your own “Environment/System”• Let MDT/SCCM handle it all: Settings,Tasks,Reporting,Events…

• Choose the right tool:• MDT LTI – Lightweight, Self Service, Cheap.• SCCM ZTI – Heavy Duty, Fully Automated.• SCCM UDI – Admin Directed with User Input.

Page 8: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

The Task SequencerTask Sequencer

VariablesOSDComputerName=PSX0304Applications1={427e7d58-9103-…}JoinDomain=Corp.Contoso.comBDEInstall=TPMDoCapture=SysPrep

Bootstrap.ini[Settings]Priority=Default[Default]DeployRoot=\\MDT01\Deploy$

CustomSettings.ini[Settings]Priority=Default,Csettings,WS[Default]JoinDomain=Corp.Contoso.comUserExit = MyCustomScript.vbs...

WizardWMI

ZTIGatherScript

WebService

[Csettings]SQLServer=SQL01…[WS]WebService=http://WS01:80Parameters=MacAddress, …

Page 9: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Customization before the Task Sequence Starts

• ZTIGather.wsf and CustomSettings.ini• Bootstrap.ini • ZTIGather.xml• UserExit.vbs

•Wizards• mdtwizardstudio.codeplex.com

• Litetouch.wsf• Edit as a last resort.

Page 10: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo Pre-Task Sequence

• ZTIGather.wsf and CustomSettings.ini• /INIFile:FileName.ini

•Wizards• Mshta.exe http://google.com• Enable Debugging in IE • Mshta.exe c:\DeploymentShare\Scripts\Wizard.hta

/definition:DeployWiz_AdminPassword.xml• SCCM – ZTIMediaHook.wsf

Page 11: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Running Custom Steps

• Import Deployment Packages• Into SCCM (Packages/Applications)• Into MDT (Applications)

• Task Sequencer may not understand every \\UNC Share•Will your steps run in all scenarios?• \\UNC• Offline USB

Page 12: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo Task Sequence

• Add Steps to the Task Sequence• Continue on Error

Page 13: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Code – Know your languageShell Ext OS Completeness WMI COM .NET Win32

NTShell .cmd All Limited (Ideal for file manipulation)

VBScript / Jscript

.vbs

.jsAll Highly Functional

(Some limitations)Yes Yes

PowerShell .ps1 WMF Fully Functional, Can call .net/Win32

Yes Yes Yes Pinvoke

C# .cs .NET Fully Functional / Compiled

Yes YES Pinvoke

C++ .c All Fully Functional / Compiled

Yes Yes Yes YES

Page 14: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Language 1 - CMD

• Been around since before Windows• Ideal language for file operations.• Variables stored in the Environment %ComputerName%

• Cmd.exe is the interpreter• Required to parse *.cmd and *.bat files.

• Some commands are native and some are external.• Copy – Native• XCopy and RoboCopy – external

Page 15: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo CMD

• Add a command to the task sequence • Native vs external

• Call a script over the network.• Scripting Best Practices.• Logging• Tip: 2>&1

Page 16: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Language 2 – VBScript

• Available on all released versions of Windows• Supports WMI and COM objects for extensibility• No direct support for .NET or Win32 API’s• Use ZTIUtility.vbs from MDT in your scripts• Logging access to bdd.log• SCCM Variables Store• Many Common routines

Page 17: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo VBS

• Example script• Error handling• On Error Resume Next

• Debugging • Cscript.exe /x File.wsf /Debug:True /DebugCapture

•Write to the bdd.log file and crash a script!

Page 18: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Language 3 – PowerShell

• One cool language!• Scripting environment of choice for Windows Server Admins• Tip: Use the built in MDT PowerShell host!• Built in Logging• Access to Task Sequence Environment

$TSEnv:OSDComputerName

Page 19: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Better Practices for PowerShell

• Use the PowerShell ISE• About_Comment_Based_Help – Self documenting• Don’t use Write-Host• Use Write-Output• Or Write-verbose• Comments…

• Documentation• Prototype with the console, use “h” to get history.

Page 20: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo PowerShell

• Commands with the ISE• Get history with PowerShell• PowerShell Best practices• PowerShell with MDT

Page 21: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Customizing the Hosts

• Just about everything can be automated on Servers.• Windows Server 2012 R2• MDT/SCCM• Hyper-V/SCVMM

• Don’t document! SCRIPT!• Don’t get hit by a bus…

Page 22: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Demo – Customizing the Hosts

• Use MDT to build the command for you.• Self Documenting!

• SCCM Automation.

Page 23: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

MMS Minnesota 2014

Resources

• DeploymentLive.com For these slides •MDT TechNet Forums for scripting help• Google/Bing Technet and StackOverflow•More Sessions!

Page 24: Customizing your Windows Deployments Tips, Tricks and Code MMS Minnesota 2014 Keith Garner @KeithGa1 DeploymentLive.com

Session Title

EvaluationsPlease provide session feedback by clicking the Eval button in the scheduler app. One lucky winner will get a free ticket to the next MMS!

Visit all of our sponsors in the expo area and online!

Platinum Sponsors:

Gold Sponsors:

MMS Minnesota 2014