practical powershell tips & tricks mms minnesota 2014 trevor sullivan, jeff wouters, david...
TRANSCRIPT
MMS Minnesota 2014
Practical PowerShell Tips & Tricks
Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs@pcgeek86 @jeffwouters @david_Obrien
#MMSMinnesota#MMSConfigMgr#MMSLove
MMS Minnesota 2014
Speaker Profile – David O’Brien
•MVP for Enterprise Client Management • Heavily focused on Automation• Blog: http://www.david-obrien.net • Twitter: @david_obrien• Principal Consultant at Dilignet in Melbourne
MMS Minnesota 2014
Speaker Profile – Trevor Sullivan
• Director of Training and Product Development @ Opsgility• Likes trying new craft beers• Passionate about spreading knowledge and awareness•Microsoft MVP for Windows PowerShell• http://trevorsullivan.net•@pcgeek86
Speaker Profile – Jeff Wouters
•MVP Windows PowerShell | BSc | MBA•MBA Psychology• Lead Infrastructure DevOps Engineer @• Scripting, Automating, darts, beer.• Blog: http://www.TheScriptingDutchman.com• Twitter: @JeffWouters
MMS Minnesota 2014
Social Media
#PSDSC#PowerShell
MMS Minnesota 2014
Agenda
• Prompt Function• Splatting (v3)•Where and ForEach Method Syntax (v4)• Classes (v5)• PSTypeNames• .NET Formatting• Variable Squeezing• Type Casting• Evaluations
Splatting (v3)
• Easier to read code• Separates input data from script logic• Downside: No Intellisense for parameters
HashTable(Parameters) Command Call
Where/ForEach Method Syntax
• Use a fluent-style syntax instead of PowerShell pipeline
Filter(Where)
Objects
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 objectsObject
PSTypeNames
PSTypeName
PSTypeName
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
MMS Minnesota 2014
PowerShell ISE Tips
• New PowerShell Tabs (Runspaces)• Invoke Intellisense• Snippets• Console vs. Script Pane• Horizontal/vertical split vs. script-only view• ISESteroids
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