MMS2014 - Customizing Your Windows Deployments

advertisement
Customizing your Windows
Deployments
Tips, Tricks and Code
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!
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!
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…
MMS Minnesota 2014
Windows Configuration Passes
Configuration
Pass
WindowsPE
Run during WinPE
OfflineServicing Run Offline
Specialize
Apply System Specific Info
Generalize
AuditSystem
AuditUser
OOBESystem
Run during Sysprep
Audit Mode (System)
Audit Mode (User)
Customize the machine
MMS Minnesota 2014
Demo Unattend.xml
• All about Unattend.xml
• Where instructions go.
• CopyProfile  Specialize
• PersistAllDeviceInstalls  Generalize
• Code: Create a Bootable VHD
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.
MMS Minnesota 2014
The Task Sequencer
Bootstrap.ini
WMI
Task Sequencer
Wizard
[Settings]
Priority=Default
[Default]
DeployRoot=\\MDT01\Deploy$
CustomSettings.ini
[Settings]
Priority=Default,Csettings,WS
[Default]
JoinDomain=Corp.Contoso.com
UserExit = MyCustomScript.vbs
...
[Csettings]
SQLServer=SQL01
…
[WS]
WebService=http://WS01:80
Parameters=MacAddress, …
ZTIGather
Script
Variables
OSDComputerName=PSX0304
Applications1={427e7d58-9103-…}
JoinDomain=Corp.Contoso.com
BDEInstall=TPM
DoCapture=SysPrep
WebService
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.
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
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
MMS Minnesota 2014
Demo Task Sequence
• Add Steps to the Task Sequence
• Continue on Error
MMS Minnesota 2014
Code – Know your language
Shell
Ext
NTShell
.cmd All
VBScript / .vbs
Jscript
.js
PowerShell .ps1
OS
Completeness
Limited (Ideal for file
manipulation)
All
Highly Functional
(Some limitations)
WMF Fully Functional, Can
call .net/Win32
WMI
COM .NET
Yes
Yes
Yes
Yes
C#
.cs
.NET
Fully Functional /
Compiled
Yes
C++
.c
All
Fully Functional /
Compiled
Yes
MMS Minnesota 2014
Yes
Win32
Yes
Pinvoke
YES
Pinvoke
Yes
YES
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
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
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
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!
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
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.
MMS Minnesota 2014
Demo PowerShell
• Commands with the ISE
• Get history with PowerShell
• PowerShell Best practices
• PowerShell with MDT
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…
MMS Minnesota 2014
Demo – Customizing the Hosts
• Use MDT to build the command for you.
• Self Documenting!
• SCCM Automation.
MMS Minnesota 2014
Resources
• DeploymentLive.com For these slides
• MDT TechNet Forums for scripting help
• Google/Bing  Technet and StackOverflow
• More Sessions!
MMS Minnesota 2014
Evaluations
Please provide session feedback by clicking the
Eval button in the scheduler app. One lucky
winner will get a free ticket to the next MMS!
Session Title
Platinum Sponsors:
Gold Sponsors:
Visit all of our sponsors in the expo area and online!
MMS Minnesota 2014
Download