SlideShare a Scribd company logo
Windows PowerShell Core Skills Tutorial Don Jones ConcentratedTech.com Learn Windows PowerShell in 2 Days / Part 1
Welcome! This is one of four sessions designed to teach specific Windows PowerShell skills Don Jones Windows PowerShell MVP Award Recipient PowerShell Columnist for  Microsoft TechNet Magazine “ Decision Maker” Columnist for  Redmond Magazine Author,  Learn Windows PowerShell in a Month of Lunches Co-Author,  Windows PowerShell v2.0: TFM Creator of numerous self-paced PowerShell training videos for CBTNuggets.com.
Caution: Demos Ahead! Please note:  This session is built primarily around demonstrations, and answering your questions. You won’t see many slides. If you’re looking for additional written resources, there are lots to choose from (including many free ones) – the closing slide will list some key URLs. We’ll be using slides mainly to form the agenda and for some conceptual stuff.
CAUTION: DEPLOY AIRBAGS! This is very much a “crash course.” We’re going to cover a lot, and we’re gonna do it quickly. Feel free to ask questions… but understand the value in “just being exposed to it.” You’ll really get the best comprehension when you start  using  these techniques in your job. So plan to do that when you go home!
Bonus I’ll post any scripts, as well as these slides. Download location will be listed at the end of this session. Don’t bother copying down commands – you’ll be able to download the whole session!
A Plug Much of what we’re covering is based on  Learn Windows PowerShell in a Month of Lunches There’s also a companion DVD that provides 99 video demos that correspond to the book I have copies with me if you’d like to take a look at them… or maybe acquire one…   Each physical copy includes a free ebook edition!
What is PowerShell? It isn’t a scripting language. It’s a command-line shell… … and like many shells, it  contains  a scripting language.  For right now, we’re going to focus on using it as a  shell.  It works a lot like the shell (Cmd.exe) you’re hopefully used to. Let’s see.
Things We Need to Cover System requirements (and the future) Cmdlets (and their names) Parameters Aliases PSProviders and PSDrives The Help System (and why not to use Get-Help) Get-Command
Parameter Confusion Parameter names can be  truncated , so long as you type enough for the shell to uniquely identify the parameter. Some parameters are  positional,  which means you can omit the parameter name if the value goes into the right spot. Get in the habit of using tab completion in the shell. I’ll show you. Also stick with always typing parameter names for now – it’s less confusing. When you use the parameter names, order doesn’t matter.
Connecting Commands Ever run  Dir | More ? If so, you know what the pipe does: It takes the output of one command and sends it to the input of the next command PowerShell can do the same thing, but it’s much more powerful (and a bit more complicated) Let’s see a couple of brief examples
Things to Cover -WhatIf and –Confirm Piping  and  Parameters (Out-File) The other Out- cmdlets Export cmdlets ConvertTo cmdlets
But Wait, There Must be More Run Get-Service… that can’t possibly be all PowerShell knows about services Let’s talk about “tables of data.” And also the Get-Member cmdlet. And also some proper terminology: Table =  Collection of objects Row =  Object Column =  Property Properties + Methods =  Members of an Object
Some Core Commands Sorting (Sort or Sort-Object) Filtering (Where or Where-Object) Picking specific properties (Select or Select-Object) This is a good time for some audience participation.
Let’s Play with Formatting PowerShell has pre-defined “views” for many types of objects – it will use those if you don’t specify something different The Format- cmdlets produce a special kind of object designed for output formatting Only Out-Host, Out-Printer, and Out-File can really make sense of those special objects Moral: If you use a Format- cmdlet, it  needs to be the last thing on the command-line .  Let’s see that, and a common “gotcha.”
Adding Commands Like the MMC, PowerShell’s main use comes when you add stuff to it. There’s a 3-step process for adding commands, finding what you added, and learning how to use them. Those 3 steps apply to the two mechanisms used to extend the shell.
Extending PowerShell PSSnapins (v1+) Get-PSSnapin –registered Add-PSSnapin  name Get-Command  –pssnapin  name Modules (v2+) Get-Module -ListAvailable Import-Module  name Get-Command -module  name Note:  It won’t list modules not installed in the correct path, but you can import using a path instead of just a name
Let’s Dig into the Pipeline More When you pipe something to a command, there’s no magical way for that command to accept that piped-in input All command input must be through a parameter So when you pipe something, PowerShell has to figure out what parameter to attach it to
Pipeline Input Plan A: ByValue Look at the TypeName of the object in the pipeline Does the receiving command have a parameter that accepts  that type  of data  from the pipeline  using the  ByValue  technique? If so, then that parameter gets the piped-in input
Plan B: ByPropertyName Only used when Plan A (ByValue) doesn’t work out Look at each property of the piped-in object(s) See if the receiving command has parameters that accept pipeline input  ByPropertyName For each receiving parameter whose name matches a property name of the input object, connect the matches
ByPropertyName Get-Service Name Status DisplayName (etc) Stop-Process Name* ID* InputObject (etc) *Accepts ByPropertyName MATCH!
Remember… The help files can  help  you to figure out what’s possible Generally, commands with the same noun will connect “properly” But you can be creative… let’s see an example using AD
Real World? Where is that CSV file likely to come from?
Fix it in the Pipeline Get-Whatever | Select-Object @{   name='wanted-property-name';   expression={$_.original-property-name} } | Do-Whatever
Or… Get-Whatever | Select-Object @{   n ='wanted-property-name';   e ={$_.original-property-name} } | Do-Whatever
Or… Get-Whatever | Select-Object @{   label ='wanted-property-name';   expression ={$_.original-property-name} } | Do-Whatever
Or… Get-Whatever | Select-Object @{   l ='wanted-property-name';   e ={$_.original-property-name} } | Do-Whatever
And Hey! You can use that same structure with Format-List and Format-Table With Format-Table you can use these keys… Expression (e) Label or Name (l or n) FormatString (N0, etc) Align (left/right) But remember: Format- goes last. So if you need to modify  and then use  an object, do it with Select-Object not Format-.
Comparisons and Filtering -eq -ne  -lt -le -gt -ge -not -and -or (parentheses) group expressions Within the –FilterScript of Where-Object, use $_ to represent “whatever was piped in”
WMI Egh. Get-WmiObject if your friend. A decent “WMI Explorer” tool is even more your friend. But let’s play with Get-WmiObject
Things to Cover… Listing classes Finding namespaces Examining classes with Get-Member Remote computers (and the protocol) Alternate credentials and authentication and a trick for credential management
Working with Bunches A “Batch” cmdlet (like Stop-Service or Restart-Computer) A WMI method that works with Invoke-WmiMethod (like Win32Shutdown() of Win32_OperatingSystem) ForEach-Object (a bit yucky – Change() of Win32_Service)
PowerShell Security Must type a path .PS1 filename association Execution Policy Unrestricted (dumb) RemoteSigned (less dumb) AllSigned (smarter) Restricted (default) Bypass (specialized) Also: PowerShell.exe switches, GPOs, etc.
Input and Output Write-Verbose Write-Debug Write-Output Read-Host Write-Host
An Intro to Variables $ is a shell cue to access the contents of a variable $var  accesses the contents of var – but the variable  name  is var, not $var ${this is a legal variable name, sadly} The VARIABLE: drive and the –Variable cmdlets [typing]$variables 'Tricks' with "Quotes" and `Escapes
A Simple, Parameterized Script Reference: [CmdletBinding()] param( [string]$whatever = 'default' )
Well, That Was Just a Lot. The story continues in the other three sessions in this series… won’t you join me tomorrow?
Thank You! Please feel free to hit me up with any remaining questions between sessions Please submit a session evaluation!  These are an extremely important part of ensuring that the conference continues to provide you with the education you need! Resources and URLs on the next slide…
Remember! Slides, and scripts will be posted within a few days. You’re welcome to download whatever you like; please don’t re-post anything elsewhere on the Internet. For the download URL, see my Twitter feed: @concentrateddon Twitter.com/concentrateddon
More PowerShell Resources Web Sites ShellHub.com Bit.ly/DonJones YouTube.com/ ConcentratedDon ITPro. ConcentratedTech.com Thank you again for attending! Available Here!

More Related Content

What's hot (20)

PPTX
Power shell basics day 8
Ashish Raj
 
PPTX
Unit testing presentation
Arthur Freyman
 
PPTX
Try harder or go home
jaredhaight
 
PPT
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
PPT
Overview of PHP and MYSQL
Deblina Chowdhury
 
PDF
Php tutorial
Niit
 
PDF
Php 5.5
Naseer Ahmad
 
PPT
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
PDF
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
PPT
PHP
sometech
 
PPT
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
PPT
Php Best Practices
Ansar Ahmed
 
PPT
Php mysql
Shehrevar Davierwala
 
PPT
Php(report)
Yhannah
 
PPT
Php Presentation
Manish Bothra
 
PPT
Introduction to PHP
Jussi Pohjolainen
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PPTX
Creating Perl modules with Dist::Zilla
Mark Gardner
 
PDF
Php a dynamic web scripting language
Elmer Concepcion Jr.
 
Power shell basics day 8
Ashish Raj
 
Unit testing presentation
Arthur Freyman
 
Try harder or go home
jaredhaight
 
Overview of PHP and MYSQL
Deblina Chowdhury
 
Php tutorial
Niit
 
Php 5.5
Naseer Ahmad
 
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Php Best Practices
Ansar Ahmed
 
Php(report)
Yhannah
 
Php Presentation
Manish Bothra
 
Introduction to PHP
Jussi Pohjolainen
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Creating Perl modules with Dist::Zilla
Mark Gardner
 
Php a dynamic web scripting language
Elmer Concepcion Jr.
 

Viewers also liked (20)

PPTX
10 PowerShell Mistakes, Trips and Traps
Jeffery Hicks
 
PPTX
Wsv406 Advanced Automation Using Windows Power Shell2.0
jsnover1
 
PPTX
Wsv315 Windows Power Shell For Beginners
jsnover1
 
PPTX
Everything you need to know about PowerShell
Shane Hoey
 
PPTX
Windows 2012 R2 Multi Server Management
Sharkrit JOBBO
 
PDF
VMUG - Mastering PowerShell to Call RESTful API Endpoints
Chris Wahl
 
PPTX
Introduction To Windows Power Shell
Microsoft TechNet
 
PPT
PowerShell 8tips
Concentrated Technology
 
PPT
Ha & drs gotcha's
Concentrated Technology
 
PPTX
Implementing dr w. hyper v clustering
Concentrated Technology
 
PPT
Automating Active Directory mgmt in PowerShell
Concentrated Technology
 
PPTX
PowerShell crash course
Concentrated Technology
 
PPTX
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
Concentrated Technology
 
PPTX
PowerShell and WMI
Concentrated Technology
 
PPTX
PowerShell crashcourse for Sharepoint admins
Concentrated Technology
 
PPTX
Ive got a powershell secret
Chris Conte
 
PPTX
Basic PowerShell Toolmaking - Spiceworld 2016 session
Rob Dunn
 
PPT
PowerShell Functions
mikepfeiffer
 
PPTX
PowerShell custom properties
Concentrated Technology
 
PPT
From VB Script to PowerShell
Concentrated Technology
 
10 PowerShell Mistakes, Trips and Traps
Jeffery Hicks
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
jsnover1
 
Wsv315 Windows Power Shell For Beginners
jsnover1
 
Everything you need to know about PowerShell
Shane Hoey
 
Windows 2012 R2 Multi Server Management
Sharkrit JOBBO
 
VMUG - Mastering PowerShell to Call RESTful API Endpoints
Chris Wahl
 
Introduction To Windows Power Shell
Microsoft TechNet
 
PowerShell 8tips
Concentrated Technology
 
Ha & drs gotcha's
Concentrated Technology
 
Implementing dr w. hyper v clustering
Concentrated Technology
 
Automating Active Directory mgmt in PowerShell
Concentrated Technology
 
PowerShell crash course
Concentrated Technology
 
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
Concentrated Technology
 
PowerShell and WMI
Concentrated Technology
 
PowerShell crashcourse for Sharepoint admins
Concentrated Technology
 
Ive got a powershell secret
Chris Conte
 
Basic PowerShell Toolmaking - Spiceworld 2016 session
Rob Dunn
 
PowerShell Functions
mikepfeiffer
 
PowerShell custom properties
Concentrated Technology
 
From VB Script to PowerShell
Concentrated Technology
 
Ad

Similar to PowerShell Core Skills (TechMentor Fall 2011) (20)

PPTX
Power shell training
David Brabant
 
PPTX
PowerShell-1
Saravanan G
 
PPTX
PowerShell 101
Thomas Lee
 
PPT
PowerShell crashcourse
Concentrated Technology
 
PPTX
PowerShell crashcourse for sharepoint
Concentrated Technology
 
PDF
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
PDF
Sql Server & PowerShell
Aaron Shilo
 
PDF
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
PPT
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
PDF
Powershell notes
Carlos Amorim
 
PPTX
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
PPTX
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PPTX
PowerShell for Penetration Testers
Nikhil Mittal
 
PPTX
In just one hour i will make you a power shell ninja
Jason Brown
 
PPTX
SVCC 5 introduction to powershell
qawarrior
 
PPT
NIIT ISAS Q5 Report - Windows PowerShell
Phan Hien
 
PPTX
Taking Advantage of Microsoft PowerShell
Global Knowledge Training
 
PDF
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
PDF
Mastering power shell - Windows
Ariel Devulsky
 
PDF
Mastering PowerShell
Fahad Noaman
 
Power shell training
David Brabant
 
PowerShell-1
Saravanan G
 
PowerShell 101
Thomas Lee
 
PowerShell crashcourse
Concentrated Technology
 
PowerShell crashcourse for sharepoint
Concentrated Technology
 
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
Sql Server & PowerShell
Aaron Shilo
 
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
Powershell notes
Carlos Amorim
 
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PowerShell for Penetration Testers
Nikhil Mittal
 
In just one hour i will make you a power shell ninja
Jason Brown
 
SVCC 5 introduction to powershell
qawarrior
 
NIIT ISAS Q5 Report - Windows PowerShell
Phan Hien
 
Taking Advantage of Microsoft PowerShell
Global Knowledge Training
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
Mastering power shell - Windows
Ariel Devulsky
 
Mastering PowerShell
Fahad Noaman
 
Ad

More from Concentrated Technology (20)

PPT
Wsus sample scripts
Concentrated Technology
 
PPTX
Wsus best practices
Concentrated Technology
 
PPT
Virtualization today
Concentrated Technology
 
PPTX
Virtualization auditing & security deck v1.0
Concentrated Technology
 
PPTX
Vdi in-a-box
Concentrated Technology
 
PPT
Top ESXi command line v2.0
Concentrated Technology
 
PPT
Supporting SQLserver
Concentrated Technology
 
PPT
Server Core2
Concentrated Technology
 
PPT
Securely connecting to apps over the internet using rds
Concentrated Technology
 
PPT
Rapidly deploying software
Concentrated Technology
 
PPT
PS scripting and modularization
Concentrated Technology
 
PPT
PS error handling and debugging
Concentrated Technology
 
PPT
Prepping software for w7 deployment
Concentrated Technology
 
PPT
PowerShell Remoting
Concentrated Technology
 
PPT
Managing SQLserver
Concentrated Technology
 
PPTX
Managing SQLserver for the reluctant DBA
Concentrated Technology
 
PPTX
Managing enterprise with PowerShell remoting
Concentrated Technology
 
PPTX
Inventory your network and clients with PowerShell
Concentrated Technology
 
PPT
Iis implementation
Concentrated Technology
 
PPT
Hyper v r2 deep dive
Concentrated Technology
 
Wsus sample scripts
Concentrated Technology
 
Wsus best practices
Concentrated Technology
 
Virtualization today
Concentrated Technology
 
Virtualization auditing & security deck v1.0
Concentrated Technology
 
Top ESXi command line v2.0
Concentrated Technology
 
Supporting SQLserver
Concentrated Technology
 
Securely connecting to apps over the internet using rds
Concentrated Technology
 
Rapidly deploying software
Concentrated Technology
 
PS scripting and modularization
Concentrated Technology
 
PS error handling and debugging
Concentrated Technology
 
Prepping software for w7 deployment
Concentrated Technology
 
PowerShell Remoting
Concentrated Technology
 
Managing SQLserver
Concentrated Technology
 
Managing SQLserver for the reluctant DBA
Concentrated Technology
 
Managing enterprise with PowerShell remoting
Concentrated Technology
 
Inventory your network and clients with PowerShell
Concentrated Technology
 
Iis implementation
Concentrated Technology
 
Hyper v r2 deep dive
Concentrated Technology
 

Recently uploaded (20)

PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PDF
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Practical Applications of AI in Local Government
OnBoard
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 

PowerShell Core Skills (TechMentor Fall 2011)

  • 1. Windows PowerShell Core Skills Tutorial Don Jones ConcentratedTech.com Learn Windows PowerShell in 2 Days / Part 1
  • 2. Welcome! This is one of four sessions designed to teach specific Windows PowerShell skills Don Jones Windows PowerShell MVP Award Recipient PowerShell Columnist for Microsoft TechNet Magazine “ Decision Maker” Columnist for Redmond Magazine Author, Learn Windows PowerShell in a Month of Lunches Co-Author, Windows PowerShell v2.0: TFM Creator of numerous self-paced PowerShell training videos for CBTNuggets.com.
  • 3. Caution: Demos Ahead! Please note: This session is built primarily around demonstrations, and answering your questions. You won’t see many slides. If you’re looking for additional written resources, there are lots to choose from (including many free ones) – the closing slide will list some key URLs. We’ll be using slides mainly to form the agenda and for some conceptual stuff.
  • 4. CAUTION: DEPLOY AIRBAGS! This is very much a “crash course.” We’re going to cover a lot, and we’re gonna do it quickly. Feel free to ask questions… but understand the value in “just being exposed to it.” You’ll really get the best comprehension when you start using these techniques in your job. So plan to do that when you go home!
  • 5. Bonus I’ll post any scripts, as well as these slides. Download location will be listed at the end of this session. Don’t bother copying down commands – you’ll be able to download the whole session!
  • 6. A Plug Much of what we’re covering is based on Learn Windows PowerShell in a Month of Lunches There’s also a companion DVD that provides 99 video demos that correspond to the book I have copies with me if you’d like to take a look at them… or maybe acquire one…  Each physical copy includes a free ebook edition!
  • 7. What is PowerShell? It isn’t a scripting language. It’s a command-line shell… … and like many shells, it contains a scripting language. For right now, we’re going to focus on using it as a shell. It works a lot like the shell (Cmd.exe) you’re hopefully used to. Let’s see.
  • 8. Things We Need to Cover System requirements (and the future) Cmdlets (and their names) Parameters Aliases PSProviders and PSDrives The Help System (and why not to use Get-Help) Get-Command
  • 9. Parameter Confusion Parameter names can be truncated , so long as you type enough for the shell to uniquely identify the parameter. Some parameters are positional, which means you can omit the parameter name if the value goes into the right spot. Get in the habit of using tab completion in the shell. I’ll show you. Also stick with always typing parameter names for now – it’s less confusing. When you use the parameter names, order doesn’t matter.
  • 10. Connecting Commands Ever run Dir | More ? If so, you know what the pipe does: It takes the output of one command and sends it to the input of the next command PowerShell can do the same thing, but it’s much more powerful (and a bit more complicated) Let’s see a couple of brief examples
  • 11. Things to Cover -WhatIf and –Confirm Piping and Parameters (Out-File) The other Out- cmdlets Export cmdlets ConvertTo cmdlets
  • 12. But Wait, There Must be More Run Get-Service… that can’t possibly be all PowerShell knows about services Let’s talk about “tables of data.” And also the Get-Member cmdlet. And also some proper terminology: Table = Collection of objects Row = Object Column = Property Properties + Methods = Members of an Object
  • 13. Some Core Commands Sorting (Sort or Sort-Object) Filtering (Where or Where-Object) Picking specific properties (Select or Select-Object) This is a good time for some audience participation.
  • 14. Let’s Play with Formatting PowerShell has pre-defined “views” for many types of objects – it will use those if you don’t specify something different The Format- cmdlets produce a special kind of object designed for output formatting Only Out-Host, Out-Printer, and Out-File can really make sense of those special objects Moral: If you use a Format- cmdlet, it needs to be the last thing on the command-line . Let’s see that, and a common “gotcha.”
  • 15. Adding Commands Like the MMC, PowerShell’s main use comes when you add stuff to it. There’s a 3-step process for adding commands, finding what you added, and learning how to use them. Those 3 steps apply to the two mechanisms used to extend the shell.
  • 16. Extending PowerShell PSSnapins (v1+) Get-PSSnapin –registered Add-PSSnapin name Get-Command –pssnapin name Modules (v2+) Get-Module -ListAvailable Import-Module name Get-Command -module name Note: It won’t list modules not installed in the correct path, but you can import using a path instead of just a name
  • 17. Let’s Dig into the Pipeline More When you pipe something to a command, there’s no magical way for that command to accept that piped-in input All command input must be through a parameter So when you pipe something, PowerShell has to figure out what parameter to attach it to
  • 18. Pipeline Input Plan A: ByValue Look at the TypeName of the object in the pipeline Does the receiving command have a parameter that accepts that type of data from the pipeline using the ByValue technique? If so, then that parameter gets the piped-in input
  • 19. Plan B: ByPropertyName Only used when Plan A (ByValue) doesn’t work out Look at each property of the piped-in object(s) See if the receiving command has parameters that accept pipeline input ByPropertyName For each receiving parameter whose name matches a property name of the input object, connect the matches
  • 20. ByPropertyName Get-Service Name Status DisplayName (etc) Stop-Process Name* ID* InputObject (etc) *Accepts ByPropertyName MATCH!
  • 21. Remember… The help files can help you to figure out what’s possible Generally, commands with the same noun will connect “properly” But you can be creative… let’s see an example using AD
  • 22. Real World? Where is that CSV file likely to come from?
  • 23. Fix it in the Pipeline Get-Whatever | Select-Object @{ name='wanted-property-name'; expression={$_.original-property-name} } | Do-Whatever
  • 24. Or… Get-Whatever | Select-Object @{ n ='wanted-property-name'; e ={$_.original-property-name} } | Do-Whatever
  • 25. Or… Get-Whatever | Select-Object @{ label ='wanted-property-name'; expression ={$_.original-property-name} } | Do-Whatever
  • 26. Or… Get-Whatever | Select-Object @{ l ='wanted-property-name'; e ={$_.original-property-name} } | Do-Whatever
  • 27. And Hey! You can use that same structure with Format-List and Format-Table With Format-Table you can use these keys… Expression (e) Label or Name (l or n) FormatString (N0, etc) Align (left/right) But remember: Format- goes last. So if you need to modify and then use an object, do it with Select-Object not Format-.
  • 28. Comparisons and Filtering -eq -ne -lt -le -gt -ge -not -and -or (parentheses) group expressions Within the –FilterScript of Where-Object, use $_ to represent “whatever was piped in”
  • 29. WMI Egh. Get-WmiObject if your friend. A decent “WMI Explorer” tool is even more your friend. But let’s play with Get-WmiObject
  • 30. Things to Cover… Listing classes Finding namespaces Examining classes with Get-Member Remote computers (and the protocol) Alternate credentials and authentication and a trick for credential management
  • 31. Working with Bunches A “Batch” cmdlet (like Stop-Service or Restart-Computer) A WMI method that works with Invoke-WmiMethod (like Win32Shutdown() of Win32_OperatingSystem) ForEach-Object (a bit yucky – Change() of Win32_Service)
  • 32. PowerShell Security Must type a path .PS1 filename association Execution Policy Unrestricted (dumb) RemoteSigned (less dumb) AllSigned (smarter) Restricted (default) Bypass (specialized) Also: PowerShell.exe switches, GPOs, etc.
  • 33. Input and Output Write-Verbose Write-Debug Write-Output Read-Host Write-Host
  • 34. An Intro to Variables $ is a shell cue to access the contents of a variable $var accesses the contents of var – but the variable name is var, not $var ${this is a legal variable name, sadly} The VARIABLE: drive and the –Variable cmdlets [typing]$variables 'Tricks' with "Quotes" and `Escapes
  • 35. A Simple, Parameterized Script Reference: [CmdletBinding()] param( [string]$whatever = 'default' )
  • 36. Well, That Was Just a Lot. The story continues in the other three sessions in this series… won’t you join me tomorrow?
  • 37. Thank You! Please feel free to hit me up with any remaining questions between sessions Please submit a session evaluation! These are an extremely important part of ensuring that the conference continues to provide you with the education you need! Resources and URLs on the next slide…
  • 38. Remember! Slides, and scripts will be posted within a few days. You’re welcome to download whatever you like; please don’t re-post anything elsewhere on the Internet. For the download URL, see my Twitter feed: @concentrateddon Twitter.com/concentrateddon
  • 39. More PowerShell Resources Web Sites ShellHub.com Bit.ly/DonJones YouTube.com/ ConcentratedDon ITPro. ConcentratedTech.com Thank you again for attending! Available Here!

Editor's Notes

  • #2: TechMentor Las Vegas 2011
  • #3: TechMentor Las Vegas 2011