SlideShare a Scribd company logo
Everything you
need to learn
PowerShell 2.0
Shane Hoey
shane@powershelldownunder.com
@shanehoey
Sponsors
What We Will Talk About
Overview of PowerShell
Explore the Basics
Start using PowerShell
Today’s Agenda
Caveat
#requires -version 2.0
I am not a Developer
PowerShell Enthusiast not an expert.
Overview
Windows PowerShell 2.0
MS-DOS - .bat
Windows 95 - Cmd
Windows 98 - Windows Scripting Host
Windows 2000 – WSH Logon scripts
3rd Party Solutions – Autoit, KiXtart, WinBatch etc
June 2003 Monad 1st Public Beta
November 2006 Windows Powershell v1.0 (rtw)
August 2009 Windows PowerShell v2.0
How did we get here ?
Windows PowerShell 2.0
Interactive shell
Scripting language
Object orientated
Highly discoverable
What is this thing ?
Windows PowerShell 2.0
Automate everything
Consistent
Sharable and reusable
Admin-Focused, Learn once, use often !
Scalable
Common engineering criteria
Why Should we use it ?
Windows PowerShell 2.0
<#Start Rant>
PowerShell is designed to be secure by default. Understand
script execution, and script signing before you change the
policy. Execution Policy determines how scripts execute
only.
Do not confuse Execution Policies with security!
<#End Rant>
Secure by Design and Secure by Default
Windows PowerShell 2.0
Don’t Compare PowerShell to other scripting languages…
And finally
Everything you need to know about PowerShell
PowerShell requires a new way of thinking!!!
Explore
Windows PowerShell 2.0
Cmdlet (pronounced “command-let”) are single feature
commands that manipulate objects. They can be executed
from the console or a script, and generally named verb-noun.
Windows 7 with no modules loaded has 236 cmdlets.
The 3 Cmdlets you must learn are Get-Help, Get-Command,
Get-Member.
CMDLET
Common Cmdlets
 Add-Computer
 Checkpoint-
Computer
 Clear-Eventlog
 Compare-Object
 Foreach-Object
 Get-Command
 Get-Credential
 Get-date
 Get-Eventlog
 Get-Help
 Get-hotfix
 Get-Location
 Get-Member
 Get-Process
 Get-Random
 Get-service
 Group-Object
 New-Object
 Remove-Computer
 Restart-computer
 SelectObject
 Set-Location
 Sort-Object
 Stop-computer
 Stop-service
 Write-Eventlog
Windows PowerShell 2.0
Always focus on the objects, every action you perform takes
place in the context of objects.
Objects are a structured collections of data that includes
the objects type, properties, and methods.
Objects
Windows PowerShell 2.0
Most objects have Properties, A property is the data that is
associated with an object, and it describes the object.
Objects of the same type have the same properties however
their values will differ.
To display a property value we can use the dot method
Properties
Windows PowerShell 2.0
Methods are a set of instructions that specify an action you can
do to that object. Most objects include at least one method.
To invoke a method specify the method name after the object,
include the arguments in parentheses, If no arguments still
include parentheses.
Methods
Windows PowerShell 2.0
A pipeline is a series of commands that are separated by the
pipeline operator |
Commands are processed left to right and processed as a single
operation.
Each pipeline sends the result of the preceding command to the
input of the next.
Once the pipeline is finished the results are generally displayed.
Pipelines
Everything you need to know…
Get-Help is your new best friend.
Retrieves help information about PowerShell.
4 main types of help available…
–full
–details
–examples
-online
Get-Help
Everything you need to know…
To list all available commands in you current PowerShell session
we use the Get-Command cmdlet.
Information comes directly from the actual commands.
Get-Command works with Cmdlets, Scripts, Alias, Functions,
Native applications.
Get-Command
Everything you need to know…
Everything PowerShell returns is an object, we use Get-
Member to obtain the properties and methods of that object.
This is one of the most important cmdlets you will learn .
Get-Member
Everything you need to know about PowerShell
Windows PowerShell 2.0
Lists available modules including “block” module
Get-Module –Listavailable
Imports the “block” module into current session
Import-Module –Name block
Its really just like playing with blocks.
Windows PowerShell 2.0
Lists all the available commands from the “block” module
Get-Command –Module block
Displays help on get-block cmdlet
Get-Help Get-block
Its really just like playing with blocks.
Windows PowerShell 2.0
Now lets look at what we can do
$Blocks = Get-Block *
Lets work out what the object is
$Blocks | Get-Member
Material – property
Colour – property
stack – method
Its really just like playing with blocks.
Windows PowerShell 2.0
Lets get all the red bricks
$redblock=$block | where-object { ($_.colour –eq “red”)
Its really just like playing with blocks.
PowerShell = Childs Play
Get the red block with the letter A
$a=$block | where-object { ($_.colour –eq “red”) –and ($_.letter –eq “A”)
Select the first blue block with the letter L
$b=$block | ?{($_.colour –eq “blue”)–and($_.letter–eq “L”) | select –first 1
Use a cmdlet join $a to $b
Stack-Block –block $b –ontopblock $a
Using .Net method to join $a to $b
($b).stack($a)
Its really just like playing with blocks.
Everything you need to know about PowerShell
Best Practices
Focus on the object.
Don’t use aliases in scripts.
Always use full parameter names.
Use cmdlets whenever possible .Net should be the exception.
or what I wish I knew when I started learning
Powershell…
Best Practices
Always use #Requires –version x.x.
Focus on doing one thing and do it well.
Focus on code reuse.
Don’t try to format objects within your script/function.
Use standard naming conventions (verb-noun).
Document your scripts and include help !
Avoid hard coding.
Designing Scripts
Best Practices
Don’t develop in production.
Use pseudo code.
Test, test & test again .
Script development
Best Practices
Always sign scripts.
Always set execution policy to Allsigned.
Never set execution policy to unrestricted or remote signed.
Always run scripts with least privilege.
Running Scripts in Production environments
Best Practices
Always configure remoting via GPO where possible.
Use Enable-PSRemoting rather than Set-WSManQuickConfig.
Remoting
Start
Related Content
Join a PowerShell Usergroup
Website http://powershelldownunder.com
Join our mailing list
Lunchtime and Evening Usergroup Meetings
Email info@powershelldownunder.com
Twitter @psdownunder
Facebook PowerShellDownUnder
LinkedIn Australian PowerShell Usergroup
or in other words a Shameless Plug
Related ContentCommunity Resourses
Forums, blogs, etc – Great Resources
powershellcommunity.org
powershell.com
Script Repository – Save you time
poshcode.org
Podcasts – Add it to Zune
powerscripting.wordpress.com
or in other words more shameless plugs
Related ContentHey Scripting Guys
http://scriptingguys.com
@scriptingguys
Hey Scripting Guy Blog – 99% PowerShell for last 18 months
Hey Scripting Guy is 7 days a week!
Script Repository – Over 4,000 scripts
Official Scripting Guys Forum – sweet!
TechNet Library content – good stuff
Related ContentPowershell Books
Windows PowerShell Step by Step
Windows PowerShell Unleashed
Windows PowerShell 2.0 Best Practices
Windows PowerShell 2.0 Administrators Pocket Consultant
Related ContentPowershell Software
PowerGUI http://www.powergui.com
PowerGUI Pro http://www.quest.com/powerguipro
Sapien http://www.sapien.com
Question and
Answer
Question and Answer Time
Presentation and Related Content will be Posted to http://bit.ly/powershell/
Everything you need to know about Windows PowerShell 2.0
Thanks For Listening!
Be sure to submit your feedback
if you want to be in the draw to
win the Xbox 360 and other prizes!
Sponsors

More Related Content

PDF
Сергей Больщиков "Protractor Tips & Tricks"
PDF
Creating Ext JS Extensions and Components
PPTX
Sencha / ExtJS : Object Oriented JavaScript
PPTX
Protractor framework – how to make stable e2e tests for Angular applications
ODP
dJango
PPTX
Basics of Ext JS
PPT
How to test models using php unit testing framework?
PPTX
Unit Testng with PHP Unit - A Step by Step Training
Сергей Больщиков "Protractor Tips & Tricks"
Creating Ext JS Extensions and Components
Sencha / ExtJS : Object Oriented JavaScript
Protractor framework – how to make stable e2e tests for Angular applications
dJango
Basics of Ext JS
How to test models using php unit testing framework?
Unit Testng with PHP Unit - A Step by Step Training

What's hot (20)

PDF
Introduction to Protractor
PPT
ExtJs Basic Part-1
PPSX
Sunil phani's take on windows powershell
PDF
Ejb3 Struts Tutorial En
PPT
Ext Js
PDF
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
PDF
Repo Madness: Taming the Open-Source Repository
ODP
Introduction to Django
PDF
UA testing with Selenium and PHPUnit - PFCongres 2013
PDF
Workshop quality assurance for php projects - ZendCon 2013
PPT
Phpunit testing
PPT
Advanced PHPUnit Testing
PDF
Why Your Test Suite Sucks - PHPCon PL 2015
PPT
What you can do In WatiR
PPTX
Developing components and extensions for ext js
PDF
watir-webdriver
PDF
New Features PHPUnit 3.3 - Sebastian Bergmann
 
PDF
Unit testing PHP apps with PHPUnit
PPTX
Laravel Unit Testing
Introduction to Protractor
ExtJs Basic Part-1
Sunil phani's take on windows powershell
Ejb3 Struts Tutorial En
Ext Js
파이썬 플라스크로 배우는 웹프로그래밍 #2 (ABCD)
Repo Madness: Taming the Open-Source Repository
Introduction to Django
UA testing with Selenium and PHPUnit - PFCongres 2013
Workshop quality assurance for php projects - ZendCon 2013
Phpunit testing
Advanced PHPUnit Testing
Why Your Test Suite Sucks - PHPCon PL 2015
What you can do In WatiR
Developing components and extensions for ext js
watir-webdriver
New Features PHPUnit 3.3 - Sebastian Bergmann
 
Unit testing PHP apps with PHPUnit
Laravel Unit Testing
Ad

Viewers also liked (11)

PPTX
Wsv315 Windows Power Shell For Beginners
PPTX
Wsv406 Advanced Automation Using Windows Power Shell2.0
PPTX
Windows 2012 R2 Multi Server Management
PDF
VMUG - Mastering PowerShell to Call RESTful API Endpoints
PPTX
Introduction To Windows Power Shell
PPT
PowerShell Scripting and Modularization (TechMentor Fall 2011)
PPTX
10 PowerShell Mistakes, Trips and Traps
PPT
PowerShell Core Skills (TechMentor Fall 2011)
PPTX
Building an Empire with PowerShell
PPTX
Introduction To Power Shell
ODP
An Introduction to Windows PowerShell
Wsv315 Windows Power Shell For Beginners
Wsv406 Advanced Automation Using Windows Power Shell2.0
Windows 2012 R2 Multi Server Management
VMUG - Mastering PowerShell to Call RESTful API Endpoints
Introduction To Windows Power Shell
PowerShell Scripting and Modularization (TechMentor Fall 2011)
10 PowerShell Mistakes, Trips and Traps
PowerShell Core Skills (TechMentor Fall 2011)
Building an Empire with PowerShell
Introduction To Power Shell
An Introduction to Windows PowerShell
Ad

Similar to Everything you need to know about PowerShell (20)

PPTX
PowerShell 101
PPTX
PowerShell-1
PPTX
2016 spice world_london_breakout
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PPTX
Introduction to PowerShell and getting started
PDF
Sql Server & PowerShell
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PPTX
Holy PowerShell, BATman! - dogfood edition
PPTX
Power shell training
PDF
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
PPT
No-script PowerShell v2
PDF
PowerShell_LangRef_v3 (1).pdf
PPTX
PowerShell 101 - What is it and Why should YOU Care!
PDF
Powershell notes
PPTX
SVCC 5 introduction to powershell
PDF
PowerShell in Depth An administrator s guide Don Jones
PPT
Powershell Seminar @ ITWorx CuttingEdge Club
PPT
Introduction to PowerShell
PDF
Introduction to PowerShell
PowerShell 101
PowerShell-1
2016 spice world_london_breakout
Windows Powershell in Action 1st Edition Bruce G. Payette
Introduction to PowerShell and getting started
Sql Server & PowerShell
Windows Powershell in Action 1st Edition Bruce G. Payette
Windows Powershell in Action 1st Edition Bruce G. Payette
Holy PowerShell, BATman! - dogfood edition
Power shell training
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
No-script PowerShell v2
PowerShell_LangRef_v3 (1).pdf
PowerShell 101 - What is it and Why should YOU Care!
Powershell notes
SVCC 5 introduction to powershell
PowerShell in Depth An administrator s guide Don Jones
Powershell Seminar @ ITWorx CuttingEdge Club
Introduction to PowerShell
Introduction to PowerShell

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Machine learning based COVID-19 study performance prediction
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Network Security Unit 5.pdf for BCA BBA.
Programs and apps: productivity, graphics, security and other tools
Machine learning based COVID-19 study performance prediction
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

Everything you need to know about PowerShell

  • 1. Everything you need to learn PowerShell 2.0 Shane Hoey shane@powershelldownunder.com @shanehoey Sponsors
  • 2. What We Will Talk About Overview of PowerShell Explore the Basics Start using PowerShell Today’s Agenda
  • 3. Caveat #requires -version 2.0 I am not a Developer PowerShell Enthusiast not an expert.
  • 5. Windows PowerShell 2.0 MS-DOS - .bat Windows 95 - Cmd Windows 98 - Windows Scripting Host Windows 2000 – WSH Logon scripts 3rd Party Solutions – Autoit, KiXtart, WinBatch etc June 2003 Monad 1st Public Beta November 2006 Windows Powershell v1.0 (rtw) August 2009 Windows PowerShell v2.0 How did we get here ?
  • 6. Windows PowerShell 2.0 Interactive shell Scripting language Object orientated Highly discoverable What is this thing ?
  • 7. Windows PowerShell 2.0 Automate everything Consistent Sharable and reusable Admin-Focused, Learn once, use often ! Scalable Common engineering criteria Why Should we use it ?
  • 8. Windows PowerShell 2.0 <#Start Rant> PowerShell is designed to be secure by default. Understand script execution, and script signing before you change the policy. Execution Policy determines how scripts execute only. Do not confuse Execution Policies with security! <#End Rant> Secure by Design and Secure by Default
  • 9. Windows PowerShell 2.0 Don’t Compare PowerShell to other scripting languages… And finally
  • 11. PowerShell requires a new way of thinking!!!
  • 13. Windows PowerShell 2.0 Cmdlet (pronounced “command-let”) are single feature commands that manipulate objects. They can be executed from the console or a script, and generally named verb-noun. Windows 7 with no modules loaded has 236 cmdlets. The 3 Cmdlets you must learn are Get-Help, Get-Command, Get-Member. CMDLET
  • 14. Common Cmdlets  Add-Computer  Checkpoint- Computer  Clear-Eventlog  Compare-Object  Foreach-Object  Get-Command  Get-Credential  Get-date  Get-Eventlog  Get-Help  Get-hotfix  Get-Location  Get-Member  Get-Process  Get-Random  Get-service  Group-Object  New-Object  Remove-Computer  Restart-computer  SelectObject  Set-Location  Sort-Object  Stop-computer  Stop-service  Write-Eventlog
  • 15. Windows PowerShell 2.0 Always focus on the objects, every action you perform takes place in the context of objects. Objects are a structured collections of data that includes the objects type, properties, and methods. Objects
  • 16. Windows PowerShell 2.0 Most objects have Properties, A property is the data that is associated with an object, and it describes the object. Objects of the same type have the same properties however their values will differ. To display a property value we can use the dot method Properties
  • 17. Windows PowerShell 2.0 Methods are a set of instructions that specify an action you can do to that object. Most objects include at least one method. To invoke a method specify the method name after the object, include the arguments in parentheses, If no arguments still include parentheses. Methods
  • 18. Windows PowerShell 2.0 A pipeline is a series of commands that are separated by the pipeline operator | Commands are processed left to right and processed as a single operation. Each pipeline sends the result of the preceding command to the input of the next. Once the pipeline is finished the results are generally displayed. Pipelines
  • 19. Everything you need to know… Get-Help is your new best friend. Retrieves help information about PowerShell. 4 main types of help available… –full –details –examples -online Get-Help
  • 20. Everything you need to know… To list all available commands in you current PowerShell session we use the Get-Command cmdlet. Information comes directly from the actual commands. Get-Command works with Cmdlets, Scripts, Alias, Functions, Native applications. Get-Command
  • 21. Everything you need to know… Everything PowerShell returns is an object, we use Get- Member to obtain the properties and methods of that object. This is one of the most important cmdlets you will learn . Get-Member
  • 23. Windows PowerShell 2.0 Lists available modules including “block” module Get-Module –Listavailable Imports the “block” module into current session Import-Module –Name block Its really just like playing with blocks.
  • 24. Windows PowerShell 2.0 Lists all the available commands from the “block” module Get-Command –Module block Displays help on get-block cmdlet Get-Help Get-block Its really just like playing with blocks.
  • 25. Windows PowerShell 2.0 Now lets look at what we can do $Blocks = Get-Block * Lets work out what the object is $Blocks | Get-Member Material – property Colour – property stack – method Its really just like playing with blocks.
  • 26. Windows PowerShell 2.0 Lets get all the red bricks $redblock=$block | where-object { ($_.colour –eq “red”) Its really just like playing with blocks.
  • 27. PowerShell = Childs Play Get the red block with the letter A $a=$block | where-object { ($_.colour –eq “red”) –and ($_.letter –eq “A”) Select the first blue block with the letter L $b=$block | ?{($_.colour –eq “blue”)–and($_.letter–eq “L”) | select –first 1 Use a cmdlet join $a to $b Stack-Block –block $b –ontopblock $a Using .Net method to join $a to $b ($b).stack($a) Its really just like playing with blocks.
  • 29. Best Practices Focus on the object. Don’t use aliases in scripts. Always use full parameter names. Use cmdlets whenever possible .Net should be the exception. or what I wish I knew when I started learning Powershell…
  • 30. Best Practices Always use #Requires –version x.x. Focus on doing one thing and do it well. Focus on code reuse. Don’t try to format objects within your script/function. Use standard naming conventions (verb-noun). Document your scripts and include help ! Avoid hard coding. Designing Scripts
  • 31. Best Practices Don’t develop in production. Use pseudo code. Test, test & test again . Script development
  • 32. Best Practices Always sign scripts. Always set execution policy to Allsigned. Never set execution policy to unrestricted or remote signed. Always run scripts with least privilege. Running Scripts in Production environments
  • 33. Best Practices Always configure remoting via GPO where possible. Use Enable-PSRemoting rather than Set-WSManQuickConfig. Remoting
  • 34. Start
  • 35. Related Content Join a PowerShell Usergroup Website http://powershelldownunder.com Join our mailing list Lunchtime and Evening Usergroup Meetings Email info@powershelldownunder.com Twitter @psdownunder Facebook PowerShellDownUnder LinkedIn Australian PowerShell Usergroup or in other words a Shameless Plug
  • 36. Related ContentCommunity Resourses Forums, blogs, etc – Great Resources powershellcommunity.org powershell.com Script Repository – Save you time poshcode.org Podcasts – Add it to Zune powerscripting.wordpress.com or in other words more shameless plugs
  • 37. Related ContentHey Scripting Guys http://scriptingguys.com @scriptingguys Hey Scripting Guy Blog – 99% PowerShell for last 18 months Hey Scripting Guy is 7 days a week! Script Repository – Over 4,000 scripts Official Scripting Guys Forum – sweet! TechNet Library content – good stuff
  • 38. Related ContentPowershell Books Windows PowerShell Step by Step Windows PowerShell Unleashed Windows PowerShell 2.0 Best Practices Windows PowerShell 2.0 Administrators Pocket Consultant
  • 39. Related ContentPowershell Software PowerGUI http://www.powergui.com PowerGUI Pro http://www.quest.com/powerguipro Sapien http://www.sapien.com
  • 40. Question and Answer Question and Answer Time Presentation and Related Content will be Posted to http://bit.ly/powershell/ Everything you need to know about Windows PowerShell 2.0
  • 41. Thanks For Listening! Be sure to submit your feedback if you want to be in the draw to win the Xbox 360 and other prizes! Sponsors