Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – @david_Obrien #MMSMinnesota #MMSConfigMgr #MMSLove
MMS Minnesota 2014 Speaker Profile – David O’Brien MVP for Enterprise Client Management Heavily focused on Automation Blog: Principal Consultant at Dilignet in Melbourne
MMS Minnesota 2014 Speaker Profile – Trevor Sullivan Director of Training and Product Opsgility Likes trying new craft beers Passionate about spreading knowledge and awareness Microsoft MVP for Windows PowerShell
Speaker Profile – Jeff Wouters MVP Windows PowerShell | BSc | MBA MBA Psychology Lead Infrastructure DevOps Scripting, Automating, darts, beer. Blog:
Social Media MMS Minnesota 2014 #PSDSC #PowerShell
Agenda Prompt Function Splatting (v3) Where and ForEach Method Syntax (v4) Classes (v5) PSTypeNames.NET Formatting Variable Squeezing Type Casting Evaluations MMS Minnesota 2014
Splatting (v3) Easier to read code Separates input data from script logic Downside: No Intellisense for parameters HashTable (Parameters) HashTable (Parameters) Command Call
Where/ForEach Method Syntax Use a fluent-style syntax instead of PowerShell pipeline Filter (Where) Filter (Where) Objects ForEach
Classes (v5) Create custom object types Add properties and methods Decorate classes with existing attributes Lexical vs. dynamic scoping of variables Class Properties Methods Constructors Overloads Static Initializers Private class members are not supported Inheritance / interfaces not supported Namespaces
PSTypeNames Append custom type names to existing objects Apply a custom type to a PSCustomObject Use the [PSTypeName()] parameter attribute to constrain input objects Object PSTypeNames PSTypeName
.NET Formatting Value substitution Date formatting Numeric formatting Custom formatters Format String Objects
Variable Squeezing Simplified syntax to assign variables and print output
Type Casting Convert objects from one type to another Explicitly declare variable types Some types support “Parse” method instead Int32 Int64
PowerShell ISE Tips New PowerShell Tabs (Runspaces) Invoke Intellisense Snippets Console vs. Script Pane Horizontal/vertical split vs. script-only view ISESteroids MMS Minnesota 2014
Session Title 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! Visit all of our sponsors in the expo area and online! Platinum Sponsors: Gold Sponsors : MMS Minnesota 2014