SlideShare a Scribd company logo
Windows PowerShellCrash Course forSharePoint AdministratorsDon JonesConcentrated Technology, LLChttp://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 @concentratdgregThis work is copyright ©Concentrated Technology, LLC
CAUTION: DEMOS AHEADThis is a demonstration-intensive session (very few slides)I will capture a shell transcript and save all of my scriptsYou can download these (in a week or so) from ConcentratedTech.com (there’s a “Conference Materials” link in the menu)
Welcome to the ShellWhy did Microsoft write PowerShell?Is this a replacement for Cmd.exe or VBScript?How much “scripting” do I need to learn?How long will PowerShell be around?What versions of Windows does it work with?What MS products are PowerShell-ed?
Command QuizChange directoriesMake a directoryGet a list of files and foldersDisplay contents of a text fileMove a fileCopy a fileDelete a file
Running CommandsRun all the commands you’re used to, with almost exactly the same syntax (Ping, Ipconfig, etc)New “cmdlets” have a more consistent naming convention and more consistent parameters… but they’re just commandsUse Help to read more; add –full or –examples for even more help; use wildcards to discover more commands and help topics
One Set of CommandsThe file system is a hierarchical data storeWhat other data stores does Windows use?Why not treat them as “disk drives” so that you can use the same set of commands?
Extending the ShellPSSnapins (the old way)Get-PSSnapin –registeredAdd-PSSnapinnameGet-Command –pssnapinnameModules (the new way)Get-Module –listavailableImport-Module nameGet-Command –module nameThere’s only one shell – the “pre-made shells” are just pre-loading a snap-in or module for you
PipingJust like Dir | MoreExport-, Out-, Format-, ConvertTo- are all useful verbs for pipingTip: Format- cmdlets go at the end of the pipeline. What they produce is only useful to Out-File, Out-Printer, Out-Host.
OutputRun Get-ProcessSee the resulting table?The real table, in memory, is much bigger – PowerShell just doesn’t show itPipe the table to Get-Member to see other available columnsOr pipe it to Format-List * (since a list can hold more data than a table)You don’t have to pipe stuff to a file and then grep it; you can simply refer to columns by name
More PipingSorting: Sort-Object (or “Sort”)Filtering: Where-Object (or “Where”)Grouping: Group-Object (or “Group”)Measuring: Measure-Object (or “Measure”)Use Format- cmdlets to specify the columns (called “properties”) that you’d prefer to see
Phys EdLet’s see the pipeline work in real life.Volunteers needed. You may win a prize.
How Pipeline input worksGet-Service generates what type of table (ok, these are really “objects” and not a “table in memory,” but it’s all just words)Get-Service | Get-MemberSo when you runGet-Service | Stop-Servicehow does Stop-Service know what to do with what you piped in?
Pipeline Input ByValueLook at the parameters of Stop-ServiceDo any of them accept pipeline input ByValue and accept the type of data being produced by Stop-Service?
Now Consider This“BITS”,”w32time” | Stop-ServiceThose are strings“BITS” | Get-MemberDoes Stop-Service accept anything of the type String ByValue from the pipeline?This would work too:Get-Content names.txt | Stop-ServiceWorld this work?Get-Process | Stop-ServiceHmmm…
Pipeline Input ByPropertyNameIf nothing will work ByValue, then the shell tries to match up input columns with parameter names ByPropertyNameLet’s look atGet-Process | Get-MemberDo any of those column names match up with parameter names of Stop-Service?Do the matching parameter names accept input from the pipeline ByPropertyName?
Debugging Pipeline InputTrace-Command-Name PipelineBinding-PSHost-expression { Get-Process | Stop-Service }
Fun trick!Import user info from a CSV and make new users out of them
WorkaroundsWhat about when pipelining won’t work?Get-WmiObject-class Win32_BIOS-computername (type names.txt)Get-WmiObject-class Win32_BIOS-computername (	Get-ADComputer –filter * |	Select –expand Name)
Remote ControlRequires PSH v2Run Enable-PSRemoting to enable(or via GPO) on machines that will accept incoming connectionsCommunicates over HTTP(s); authenticates with KerberosHelp about_remote* for more help
1:1, 1:n RemotingEnter-PSSession –computernamexExit-PSSessionInvoke-Command-scriptblock { command(s) }-computernamex,x,x,xNotes:PSComputerName propertyFilePath switch to do a whole script
More Options-credential-port-useSSLEtcOr create a persistent session using New-PSSession.Get the sessions with Get-PSSessionInvoke-Command –scr { whatever }-session (Get-PSSession)
Implicit RemotingStart a session (maybe save it in a $variable for ease of referring to it)Import a module in the remote sessionImport the remote session into the local shell – just the commands from that module, and add a noun prefixExecute remote commands as if they were local!
WMIGet-WmiObject-class whatever (e.g., “Win32_XXX”)-computername x,y,z-EA SilentlyContinue (why?)-Filter ”something” (why?)Let’s play with that…
Awesome Advanced TrickFormat-Table can accept a special item called a hashtable or dictionary as a property in a property listThe dictionary must contain two itemsN: The name of the column you want to createE: The value to go into the columnThis can even be an entirely new command!Use $_ to refer to whatever table row (object) is currentUse to combine WMI info from two classes into a single output! Crazy syntax, but crazy useful!
NOW… let’s do some Q&AI’ve got more demos to show you, but want to make sure I address your questionsAsk ‘em now!The remainder of the session will be additional demosRemember: Transcript will be downloadable; no need to copy down the syntaxAsk for a “reminder card” if you want to download this stuff next week.
Final Notes…Please be sure to submit a session evaluation form!Download slides & materials from www.ConcentratedTech.com within one week!Blog, URLs, and other information is also available at www.ConcentratedTech.com for your referenceMore resources at www.ShellHub.comThank you very much!
Your Feedback is ImportantPlease fill out a session evaluation form.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 @concentratdgregThis work is copyright ©Concentrated Technology, LLC

More Related Content

PPTX
PowerShell crashcourse for sharepoint
PPT
PowerShell 8tips
PPT
PowerShell crashcourse
PPT
PowerShell Remoting
PPT
From VB Script to PowerShell
PPTX
PowerShell custom properties
PPT
PPT
PS error handling and debugging
PowerShell crashcourse for sharepoint
PowerShell 8tips
PowerShell crashcourse
PowerShell Remoting
From VB Script to PowerShell
PowerShell custom properties
PS error handling and debugging

What's hot (20)

PPT
Supporting SQLserver
PPT
PS scripting and modularization
PPT
Prepping software for w7 deployment
PPT
Top ESXi command line v2.0
PPT
Automating ad with powershell
PPTX
Virtualization auditing & security deck v1.0
PPT
Automating Active Directory mgmt in PowerShell
PDF
Drupal Camp LA 2011: Typography modules for Drupal
PPTX
Drupal Backend Performance and Scalability
PPTX
Ideal Deployment In .NET World
PPTX
Pantheon basics
PDF
Session on Selenium Powertools by Unmesh Gundecha
KEY
Features, Exportables & You
PPS
Install WordPress Blogging Software with EasyPHP
PDF
Keep Applications Online
PPTX
Automating Post Exploitation with PowerShell
PPT
LivePC creation webcast
PPTX
Kautilya: Teensy beyond shell
PPTX
Domino Security - not knowing is not an option (2016 edition)
PDF
WordPress Security - 12 WordPress Security Fundamentals
Supporting SQLserver
PS scripting and modularization
Prepping software for w7 deployment
Top ESXi command line v2.0
Automating ad with powershell
Virtualization auditing & security deck v1.0
Automating Active Directory mgmt in PowerShell
Drupal Camp LA 2011: Typography modules for Drupal
Drupal Backend Performance and Scalability
Ideal Deployment In .NET World
Pantheon basics
Session on Selenium Powertools by Unmesh Gundecha
Features, Exportables & You
Install WordPress Blogging Software with EasyPHP
Keep Applications Online
Automating Post Exploitation with PowerShell
LivePC creation webcast
Kautilya: Teensy beyond shell
Domino Security - not knowing is not an option (2016 edition)
WordPress Security - 12 WordPress Security Fundamentals
Ad

Viewers also liked (20)

PPT
No-script PowerShell v2
PPTX
Managing SQLserver for the reluctant DBA
PPT
Free tools for rapidly deploying software
PPT
Ad disasters & how to prevent them
PPT
Free tools for win server administration
PDF
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
PPT
Managing SQLserver
PPTX
Managing enterprise with PowerShell remoting
PPTX
Implementing dr w. hyper v clustering
PPT
Ha & drs gotcha's
PPTX
PowerShell crash course
PPTX
Best free tools for win database admin
PPTX
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
PPT
PowerShell Functions
PPTX
Introduction to powershell
PPTX
Three cool cmdlets I wish PowerShell Had!
PPTX
PowerShell and WMI
KEY
PowerShell and the Future of Windows Automation
PPTX
Basic PowerShell Toolmaking - Spiceworld 2016 session
PPTX
Meet Windows PowerShell
No-script PowerShell v2
Managing SQLserver for the reluctant DBA
Free tools for rapidly deploying software
Ad disasters & how to prevent them
Free tools for win server administration
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Managing SQLserver
Managing enterprise with PowerShell remoting
Implementing dr w. hyper v clustering
Ha & drs gotcha's
PowerShell crash course
Best free tools for win database admin
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
PowerShell Functions
Introduction to powershell
Three cool cmdlets I wish PowerShell Had!
PowerShell and WMI
PowerShell and the Future of Windows Automation
Basic PowerShell Toolmaking - Spiceworld 2016 session
Meet Windows PowerShell
Ad

Similar to PowerShell crashcourse for Sharepoint admins (20)

PPT
PowerShell Core Skills (TechMentor Fall 2011)
PPT
Powershell Seminar @ ITWorx CuttingEdge Club
PPTX
PowerShell-1
PPSX
Sunil phani's take on windows powershell
PPTX
PowerShellForDBDevelopers
PPTX
PowerShell 101
PDF
Sql Server & PowerShell
PDF
WORKING WITH FILE AND PIPELINE PARAMETER BINDING
PPTX
Power Shell for System Admins - By Kaustubh
PPTX
SVCC 5 introduction to powershell
PPTX
2016 spice world_london_breakout
PPTX
Windows PowerShell
PPT
Introduction to PowerShell
PDF
Basic commands for powershell : Configuring Windows PowerShell and working wi...
PPTX
Introduction To Power Shell
PPT
Why and How Powershell will rule the Command Line - Barcamp LA 4
PPTX
02Introduction to Power Shell Win Server all in one.pptx
PPTX
Windows power shell basics
PPTX
Command Line And Power Shell
PDF
Windows PowerShell Step by Step 3rd Edition Wilson
PowerShell Core Skills (TechMentor Fall 2011)
Powershell Seminar @ ITWorx CuttingEdge Club
PowerShell-1
Sunil phani's take on windows powershell
PowerShellForDBDevelopers
PowerShell 101
Sql Server & PowerShell
WORKING WITH FILE AND PIPELINE PARAMETER BINDING
Power Shell for System Admins - By Kaustubh
SVCC 5 introduction to powershell
2016 spice world_london_breakout
Windows PowerShell
Introduction to PowerShell
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Introduction To Power Shell
Why and How Powershell will rule the Command Line - Barcamp LA 4
02Introduction to Power Shell Win Server all in one.pptx
Windows power shell basics
Command Line And Power Shell
Windows PowerShell Step by Step 3rd Edition Wilson

More from Concentrated Technology (10)

PPT
Wsus sample scripts
PPTX
Wsus best practices
PPT
Virtualization today
PPTX
PPT
Securely connecting to apps over the internet using rds
PPT
Rapidly deploying software
PPTX
Inventory your network and clients with PowerShell
PPT
Iis implementation
PPT
Hyper v r2 deep dive
PPT
How to configure esx to pass an audit
Wsus sample scripts
Wsus best practices
Virtualization today
Securely connecting to apps over the internet using rds
Rapidly deploying software
Inventory your network and clients with PowerShell
Iis implementation
Hyper v r2 deep dive
How to configure esx to pass an audit

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Big Data Technologies - Introduction.pptx
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25 Week I
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
Cloud computing and distributed systems.

PowerShell crashcourse for Sharepoint admins

  • 1. Windows PowerShellCrash Course forSharePoint AdministratorsDon JonesConcentrated Technology, LLChttp://concentratedtech.com
  • 2. 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 @concentratdgregThis work is copyright ©Concentrated Technology, LLC
  • 3. CAUTION: DEMOS AHEADThis is a demonstration-intensive session (very few slides)I will capture a shell transcript and save all of my scriptsYou can download these (in a week or so) from ConcentratedTech.com (there’s a “Conference Materials” link in the menu)
  • 4. Welcome to the ShellWhy did Microsoft write PowerShell?Is this a replacement for Cmd.exe or VBScript?How much “scripting” do I need to learn?How long will PowerShell be around?What versions of Windows does it work with?What MS products are PowerShell-ed?
  • 5. Command QuizChange directoriesMake a directoryGet a list of files and foldersDisplay contents of a text fileMove a fileCopy a fileDelete a file
  • 6. Running CommandsRun all the commands you’re used to, with almost exactly the same syntax (Ping, Ipconfig, etc)New “cmdlets” have a more consistent naming convention and more consistent parameters… but they’re just commandsUse Help to read more; add –full or –examples for even more help; use wildcards to discover more commands and help topics
  • 7. One Set of CommandsThe file system is a hierarchical data storeWhat other data stores does Windows use?Why not treat them as “disk drives” so that you can use the same set of commands?
  • 8. Extending the ShellPSSnapins (the old way)Get-PSSnapin –registeredAdd-PSSnapinnameGet-Command –pssnapinnameModules (the new way)Get-Module –listavailableImport-Module nameGet-Command –module nameThere’s only one shell – the “pre-made shells” are just pre-loading a snap-in or module for you
  • 9. PipingJust like Dir | MoreExport-, Out-, Format-, ConvertTo- are all useful verbs for pipingTip: Format- cmdlets go at the end of the pipeline. What they produce is only useful to Out-File, Out-Printer, Out-Host.
  • 10. OutputRun Get-ProcessSee the resulting table?The real table, in memory, is much bigger – PowerShell just doesn’t show itPipe the table to Get-Member to see other available columnsOr pipe it to Format-List * (since a list can hold more data than a table)You don’t have to pipe stuff to a file and then grep it; you can simply refer to columns by name
  • 11. More PipingSorting: Sort-Object (or “Sort”)Filtering: Where-Object (or “Where”)Grouping: Group-Object (or “Group”)Measuring: Measure-Object (or “Measure”)Use Format- cmdlets to specify the columns (called “properties”) that you’d prefer to see
  • 12. Phys EdLet’s see the pipeline work in real life.Volunteers needed. You may win a prize.
  • 13. How Pipeline input worksGet-Service generates what type of table (ok, these are really “objects” and not a “table in memory,” but it’s all just words)Get-Service | Get-MemberSo when you runGet-Service | Stop-Servicehow does Stop-Service know what to do with what you piped in?
  • 14. Pipeline Input ByValueLook at the parameters of Stop-ServiceDo any of them accept pipeline input ByValue and accept the type of data being produced by Stop-Service?
  • 15. Now Consider This“BITS”,”w32time” | Stop-ServiceThose are strings“BITS” | Get-MemberDoes Stop-Service accept anything of the type String ByValue from the pipeline?This would work too:Get-Content names.txt | Stop-ServiceWorld this work?Get-Process | Stop-ServiceHmmm…
  • 16. Pipeline Input ByPropertyNameIf nothing will work ByValue, then the shell tries to match up input columns with parameter names ByPropertyNameLet’s look atGet-Process | Get-MemberDo any of those column names match up with parameter names of Stop-Service?Do the matching parameter names accept input from the pipeline ByPropertyName?
  • 17. Debugging Pipeline InputTrace-Command-Name PipelineBinding-PSHost-expression { Get-Process | Stop-Service }
  • 18. Fun trick!Import user info from a CSV and make new users out of them
  • 19. WorkaroundsWhat about when pipelining won’t work?Get-WmiObject-class Win32_BIOS-computername (type names.txt)Get-WmiObject-class Win32_BIOS-computername ( Get-ADComputer –filter * | Select –expand Name)
  • 20. Remote ControlRequires PSH v2Run Enable-PSRemoting to enable(or via GPO) on machines that will accept incoming connectionsCommunicates over HTTP(s); authenticates with KerberosHelp about_remote* for more help
  • 21. 1:1, 1:n RemotingEnter-PSSession –computernamexExit-PSSessionInvoke-Command-scriptblock { command(s) }-computernamex,x,x,xNotes:PSComputerName propertyFilePath switch to do a whole script
  • 22. More Options-credential-port-useSSLEtcOr create a persistent session using New-PSSession.Get the sessions with Get-PSSessionInvoke-Command –scr { whatever }-session (Get-PSSession)
  • 23. Implicit RemotingStart a session (maybe save it in a $variable for ease of referring to it)Import a module in the remote sessionImport the remote session into the local shell – just the commands from that module, and add a noun prefixExecute remote commands as if they were local!
  • 24. WMIGet-WmiObject-class whatever (e.g., “Win32_XXX”)-computername x,y,z-EA SilentlyContinue (why?)-Filter ”something” (why?)Let’s play with that…
  • 25. Awesome Advanced TrickFormat-Table can accept a special item called a hashtable or dictionary as a property in a property listThe dictionary must contain two itemsN: The name of the column you want to createE: The value to go into the columnThis can even be an entirely new command!Use $_ to refer to whatever table row (object) is currentUse to combine WMI info from two classes into a single output! Crazy syntax, but crazy useful!
  • 26. NOW… let’s do some Q&AI’ve got more demos to show you, but want to make sure I address your questionsAsk ‘em now!The remainder of the session will be additional demosRemember: Transcript will be downloadable; no need to copy down the syntaxAsk for a “reminder card” if you want to download this stuff next week.
  • 27. Final Notes…Please be sure to submit a session evaluation form!Download slides & materials from www.ConcentratedTech.com within one week!Blog, URLs, and other information is also available at www.ConcentratedTech.com for your referenceMore resources at www.ShellHub.comThank you very much!
  • 28. Your Feedback is ImportantPlease fill out a session evaluation form.Thank you!
  • 29. 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 @concentratdgregThis work is copyright ©Concentrated Technology, LLC