Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien...
-
Upload
susanna-patrick -
Category
Documents
-
view
215 -
download
0
Transcript of Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien...
![Page 1: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/1.jpg)
MMS Minnesota 2014
Practical PowerShell Tips & Tricks
Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs@pcgeek86 @jeffwouters @david_Obrien
#MMSMinnesota#MMSConfigMgr#MMSLove
![Page 2: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/2.jpg)
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
![Page 3: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/3.jpg)
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
![Page 4: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/4.jpg)
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
![Page 5: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/5.jpg)
MMS Minnesota 2014
Social Media
#PSDSC#PowerShell
![Page 6: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/6.jpg)
MMS Minnesota 2014
Agenda
• Prompt Function• Splatting (v3)•Where and ForEach Method Syntax (v4)• Classes (v5)• PSTypeNames• .NET Formatting• Variable Squeezing• Type Casting• Evaluations
![Page 7: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/7.jpg)
Splatting (v3)
• Easier to read code• Separates input data from script logic• Downside: No Intellisense for parameters
HashTable(Parameters) Command Call
![Page 8: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/8.jpg)
Where/ForEach Method Syntax
• Use a fluent-style syntax instead of PowerShell pipeline
Filter(Where)
Objects
Objects
ForEach
![Page 9: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/9.jpg)
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
![Page 10: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/10.jpg)
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
![Page 11: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/11.jpg)
.NET Formatting
• Value substitution• Date formatting• Numeric formatting• Custom formatters
Format String Objects
![Page 12: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/12.jpg)
Variable Squeezing
• Simplified syntax to assign variables and print output
![Page 13: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/13.jpg)
Type Casting
• Convert objects from one type to another• Explicitly declare variable types• Some types support “Parse” method instead
Int32 Int64
![Page 14: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/14.jpg)
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
![Page 15: Practical PowerShell Tips & Tricks MMS Minnesota 2014 Trevor Sullivan, Jeff Wouters, David O’Brien – Microsoft MVPs @pcgeek86 @jeffwouters @david_Obrien.](https://reader035.fdocuments.us/reader035/viewer/2022062421/56649d825503460f94a675ee/html5/thumbnails/15.jpg)
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