Post on 05-Dec-2014
description
75-Minute PowerShellCrash Course
Don Jones
Concentrated Technology
http://ConcentratedTech.com
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it
within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please
visit our Web site, www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC
Welcome!
• This is a demo-intensive session• I will capture a shell transcript, which will be
downloadable from ConcentratedTech.com next week
• We will be covering key PowerShell usage patterns, using real-world tasks as our examples
• Learn these patterns and you can teach yourself to do anything you need to in PowerShell!
Loading Extensions, Learning Commands
• Snap-ins● Get-PSSnapin –registered● Add-PSSnapin name● Get-Command –pssnapin name
• Modules● Get-Module –listAvailable● Import-Module name● Get-Command –module name
• Help
Cmdlet and Parameter Names
• Verb-Noun (singular)• -parameter value• “quotes” or ‘quotes’ around strings
(especially those with spaces)• Use wildcards with Help• Use –full, -example, and –online with Help• Use Get-Command
Piping
• Like Dir | More only better• Pipeline binding ByValue• Pipeline binding ByPropertyName
Tables of Information
• Use Get-Member to see all “columns”• Okay, these are really objects
● Column = Property● Row = Object (instance)
• Use Format-List, Format-Wide, and Format-Table
• Wildcards work with –property param
Manipulating Objects
• Sorting• Measuring• Selecting subsets• Selecting specific properties (columns)
Custom Property Syntax
• Works with –property parameter of Select-Object, Format-List, and Format-Table
• @{n=’col_name’;e={$_.expression}}
• Use this to bind ComputerName ByPropertyname
Two More Ways of GettingComputer Names
• (parentheses) with Select-Object –expand• (parentheses) with Get-Content
Comparison Operators
• -eq, -ne• -ge, -gt• -le, -lt• -list (use * as wildcard)
• All case-sensitive• Use –ceq, -cne, etc. for case-sensitive
Filtering Objects
• Use Where-Object –filterscript {}• $_ represents the current row (object) that
was piped in
WMI
• Use Get-WmiObject• Specify –class and –namespace (unless
it’s root\CIMv2)• Specify –filter (WQL syntax, not
PowerShell)• Pipe to Sort, Select, Where, etc.• Drive inventory anyone?• Use WMI Explorer to locate stuff
Making Things Happen
• Batch Cmdlets• Invoke-WmiMethod• ForEach-Object ($_ again!)
Scripting
• Security (Get/Set-ExecutionPolicy)• .PS1 filename extension• Parameterizing a script• Script Function• Dot-sourcing functions• Creating “script modules”
That was a lot.
• There’s a ton more…• Learn it all in an hour a day with Learn
Windows PowerShell in a Month of Lunches● Companion DVD includes 99 demo videos
that align with each chapter
Final Q&A
• Text DONJ to 50500 for contact info
• See me for add’l resources
● Books● Workshop recordings● Demo videos● Etc
• Slide decks posted to ConcentratedTech.com by next week
Your Feedback is Important
Please fill out a session evaluation form drop it off at the conference registration
desk.
Thank you!
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it
within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please
visit our Web site, www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC