SlideShare a Scribd company logo
4
Most read
7
Most read
11
Most read
Windows PowerShell
Sandun Perera
Geveo Australasia
30th May 2012
 Command line interpreter
 Unix shell
 Apple script
 MS-DOS
 Windows Script Host
 Windows PowerShell
 Administrative tasks
 Routine tasks
 Maintenance tasks
Shell scripting
 1. Install Microsoft .NET Framework 2.0
 2. Install Microsoft .NET Framework 3.5.1.
 Required for Windows PowerShell Integrated Scripting
Environment (ISE) and Out-GridView.
 3. Install WinRM 2.0 CTP3. (Windows Remote Shell)
 This is required if you want to take advantage of the remoting and
back- ground jobs features.
 4. Install Windows PowerShell 2.
Starting point (ps2)
Integrated Scripting Environment
(ISE)
 Set Execution Policy
 Customise Console
 Profile editing
 Profile using
Permission and Profiling
Cmdlets
Windows
PowerShell
(Cmdlet)
Windows PowerShell
(Alias)
cmd.exe /
COMMAND.COM
(MS-DOS, Windows,
OS/2, etc.)
Description
Get-Location gl, pwd cd Display the current directory/present working directory.
Set-Location sl, cd, chdir cd, chdir Change the current directory
Clear-Host cls, clear cls Clear the screen
Copy-Item cpi, copy, cp copy Copy one or several files / a whole directory tree
Get-Help help, man help Help on commands
Remove-Item ri, del, erase, rmdir, rd, rm del, erase, rmdir, rd Delete a file / a directory
Rename-Item rni, ren ren, rename Rename a file / a directory
Move-Item mi, move, mv move Move a file / a directory to a new location
Get-ChildItem gci, dir, ls dir List all files / directories in the (current) directory
Write-Output echo, write echo Print strings, variables etc. to standard output
Pop-Location popd popd
Change the current directory to the directory most recently
pushed onto the stack
Push-Location pushd pushd Push the current directory onto the stack
Set-Variable sv, set set Set the value of a variable / create a variable
 Boolean: True or false condition.
 Byte: An 8-bit unsigned whole number from 0 to 255, such as 32.
 Char: A 16-bit unsigned whole number from 0 to 65,535. For example, 1,026.
 Date: A calendar date, such as January 1, 2009.
 Decimal: A 128-bit decimal value, such as 3.14159265.
 Double: A double-precision 64-bit floating point number. In effect, this is another kind of
decimal value but has a narrower range of values than a decimal.
 Integer: A 32-bit signed whole number from –2,147,483,648 to 2,147,483,647, such as 152 or –
1839.
 Long: A 64-bit signed whole number. This is like an integer but holds far more values, such as
9,233,372,036,854,775,807.
 Object: Any kind of object.
 Short: A 16-bit unsigned whole number. This is like an integer but holds far fewer values. It
can only hold values from –32,768 to 32,767.
 Single: A single-precision 32-bit floating point number. This is like a double but holds far
fewer values, such as 20.3654.
 String: A grouping of characters that most people just call text.
Data types
 $MyVariable
 $AVariableWithANumber6
 ${A variable with spaces}
 ${A variable with special characters @#%%}
Variables
 $Error: An array of error objects representing the most recent errors.
 $Host: Current host application for Windows PowerShell.
 $Profile: Stores the full path to the Windows PowerShell user profile for
the default shell.
 $PID: Contains the process identifier of the Windows PowerShell
process.
 $PSUICulture: Stores the name of the UI culture currently in use.
 $NULL: Contains NULL or empty value.
 $False: Contains FALSE.
 $True: Contains TRUE.
Automatic variables
 Concatenating
 Escape characters
 Multiline string
 String functions
String handling
 Backslash: 
 Dollar sign: $
 Dot: .
 Pipe: |
 Question mark: ?
 Star: *
 Plus sign: +
 Open square bracket: [
 Open parenthesis: (
 Close parenthesis: )
 Caret: ^
Regular expressions
 Create functions
 Calling functions
 Passing arguments
 Return values
Functions
Operator Meaning
-eq Equal
-ne Not equal
-ine Not equal; not case sensitive (new in Windows PowerShell 2)
-lt Less than
-le Less than or equal
-gt Greater than
-ge Greater than or equal
Operators
 if statement
 switch statement
 for loop
 foreach loop
 while loop
 do while loop
 do until loop
Control flow statements
 Add (adds a Timespan value)
 AddDays
 AddHours
 AddMilliseconds
 AddMinutes
 AddMonths
 AddSeconds
 AddTicks
 AddYears
DateTime
 Arrays
 Hash tables
 Access elements
Collections
 Reading files
 Writing file
 Create files
 Delete files
 Copy / Rename / Move files
File handling
 Access system information
 Disk info
 Services
 Event log
 BIOS
Windows Management
Infrastructure (WMI)
 Connect to SQL Server
 Create SQL Command
 Execute and capture data
 Display data
SQL Query Execution
 Count errors
 Throw exception
 Handle exception
 Write to log file
 Write to Event log
Exception handling
 Message box
 Installed drivers info
 Path shrink
 Convert to PDF
 Send email
 Hello Anna
 Text to audio recording
Cool stuff
 Not allowing scripts to execute
 Improperly using commas to separate parameters when
calling a function
 Not defining functions before using them
 Forgetting that pipelines pass objects and not just strings
 Not casting variables as a string
 Making incorrect comparisons
 Expending the pipeline to far
 Not taking variable scope in account
 Debugging without the debugger
 Forgetting to use available .NET classes
Common Mistakes
 Windows PowerShell™ 2 For Dummies® by Steve Seguis
 http://powershell.com/cs/
 http://en.wikipedia.org/wiki/Windows_PowerShell
 http://sandunangelo.blogspot.com/2010/02/introduction-to-
powershell-scripting.html
References
Thank you!

More Related Content

PDF
Introduction to PowerShell
Boulos Dib
 
PPTX
Apache web server
Sabiha M
 
PPTX
Powershell Demo Presentation
Avik Bhattacharyya
 
PDF
DNS exfiltration using sqlmap
Miroslav Stampar
 
PPTX
Unix
Erm78
 
PPSX
Introduction to Java
Hitesh-Java
 
PPTX
I hunt sys admins 2.0
Will Schroeder
 
PDF
Introduction to LDAP and Directory Services
Radovan Semancik
 
Introduction to PowerShell
Boulos Dib
 
Apache web server
Sabiha M
 
Powershell Demo Presentation
Avik Bhattacharyya
 
DNS exfiltration using sqlmap
Miroslav Stampar
 
Unix
Erm78
 
Introduction to Java
Hitesh-Java
 
I hunt sys admins 2.0
Will Schroeder
 
Introduction to LDAP and Directory Services
Radovan Semancik
 

What's hot (20)

PPTX
High Performance Computing (HPC) in cloud
Accubits Technologies
 
PPTX
Document Object Model
Mayur Mudgal
 
PPTX
User management
Mufaddal Haidermota
 
PPT
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
PPT
7.data types in c#
Zeeshan Ahmad
 
PPTX
Filepermissions in linux
Subashini Pandiarajan
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPT
Linux
Gouthaman V
 
PPTX
Systems Administration
Mark John Lado, MIT
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PPT
Php Presentation
Manish Bothra
 
PPTX
PowerShell-1
Saravanan G
 
PPTX
Apache web service
Manash Kumar Mondal
 
PDF
Object-oriented Programming-with C#
Doncho Minkov
 
PDF
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
PDF
Java - Exception Handling Concepts
Victer Paul
 
PPTX
Visual studio code
MVP Microsoft
 
PPTX
Sqlmap
Rushikesh Kulkarni
 
PPT
Introduction to PowerShell
Salaudeen Rajack
 
PDF
How fun of privilege escalation Red Pill2017
Ammarit Thongthua ,CISSP CISM GXPN CSSLP CCNP
 
High Performance Computing (HPC) in cloud
Accubits Technologies
 
Document Object Model
Mayur Mudgal
 
User management
Mufaddal Haidermota
 
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
7.data types in c#
Zeeshan Ahmad
 
Filepermissions in linux
Subashini Pandiarajan
 
Methods in Java
Jussi Pohjolainen
 
Systems Administration
Mark John Lado, MIT
 
PHP FUNCTIONS
Zeeshan Ahmed
 
Php Presentation
Manish Bothra
 
PowerShell-1
Saravanan G
 
Apache web service
Manash Kumar Mondal
 
Object-oriented Programming-with C#
Doncho Minkov
 
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
Java - Exception Handling Concepts
Victer Paul
 
Visual studio code
MVP Microsoft
 
Introduction to PowerShell
Salaudeen Rajack
 
How fun of privilege escalation Red Pill2017
Ammarit Thongthua ,CISSP CISM GXPN CSSLP CCNP
 
Ad

Similar to Windows PowerShell (20)

PPTX
PowerShell 101
Thomas Lee
 
PDF
PowerShell_LangRef_v3 (1).pdf
outcast96
 
PPT
NIIT ISAS Q5 Report - Windows PowerShell
Phan Hien
 
PPT
No-script PowerShell v2
Concentrated Technology
 
PPTX
Power shell training
David Brabant
 
PPT
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
PDF
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
PDF
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
PPTX
Holy PowerShell, BATman! - dogfood edition
Dave Diehl
 
PPTX
Powershell Tech Ed2009
rsnarayanan
 
PPT
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
PPTX
PowerShell 101
Thomas Lee
 
PPTX
Get-Help: An intro to PowerShell and how to Use it for Evil
jaredhaight
 
PPTX
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PDF
Sql Server & PowerShell
Aaron Shilo
 
PDF
Powershell notes
Carlos Amorim
 
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
takabedembe
 
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
zahithovor
 
PPTX
learn ps new advance for all powershell.pptx
Ronnie Kapoor
 
PPTX
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
PowerShell 101
Thomas Lee
 
PowerShell_LangRef_v3 (1).pdf
outcast96
 
NIIT ISAS Q5 Report - Windows PowerShell
Phan Hien
 
No-script PowerShell v2
Concentrated Technology
 
Power shell training
David Brabant
 
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
ClapperboardCinemaPV
 
Holy PowerShell, BATman! - dogfood edition
Dave Diehl
 
Powershell Tech Ed2009
rsnarayanan
 
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
PowerShell 101
Thomas Lee
 
Get-Help: An intro to PowerShell and how to Use it for Evil
jaredhaight
 
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
Sql Server & PowerShell
Aaron Shilo
 
Powershell notes
Carlos Amorim
 
Windows Powershell in Action 1st Edition Bruce G. Payette
takabedembe
 
Windows Powershell in Action 1st Edition Bruce G. Payette
zahithovor
 
learn ps new advance for all powershell.pptx
Ronnie Kapoor
 
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
Ad

More from Sandun Perera (12)

PPTX
Azure EventGrid vs Azure ServiceBus.pptx
Sandun Perera
 
PPTX
iUpgradable
Sandun Perera
 
PPTX
Bootstrap 5 whats new
Sandun Perera
 
PPTX
Blazor
Sandun Perera
 
PPTX
Angular Form Validations
Sandun Perera
 
PPTX
Introduction to NuoDB
Sandun Perera
 
PPTX
Microsoft Dynamics CRM 2013 Customization
Sandun Perera
 
PPTX
SQL Windowing
Sandun Perera
 
PPTX
Car care
Sandun Perera
 
PPTX
Tale of the photo camera
Sandun Perera
 
PPTX
Visual Studio Unleashed - Tips and Tricks
Sandun Perera
 
PPTX
What’s new in Visual Studio 2010
Sandun Perera
 
Azure EventGrid vs Azure ServiceBus.pptx
Sandun Perera
 
iUpgradable
Sandun Perera
 
Bootstrap 5 whats new
Sandun Perera
 
Angular Form Validations
Sandun Perera
 
Introduction to NuoDB
Sandun Perera
 
Microsoft Dynamics CRM 2013 Customization
Sandun Perera
 
SQL Windowing
Sandun Perera
 
Car care
Sandun Perera
 
Tale of the photo camera
Sandun Perera
 
Visual Studio Unleashed - Tips and Tricks
Sandun Perera
 
What’s new in Visual Studio 2010
Sandun Perera
 

Recently uploaded (20)

PPTX
Smart Panchayat Raj e-Governance App.pptx
Rohitnikam33
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Smart Panchayat Raj e-Governance App.pptx
Rohitnikam33
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
Presentation about variables and constant.pptx
kr2589474
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Exploring AI Agents in Process Industries
amoreira6
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 

Windows PowerShell

  • 1. Windows PowerShell Sandun Perera Geveo Australasia 30th May 2012
  • 2.  Command line interpreter  Unix shell  Apple script  MS-DOS  Windows Script Host  Windows PowerShell  Administrative tasks  Routine tasks  Maintenance tasks Shell scripting
  • 3.  1. Install Microsoft .NET Framework 2.0  2. Install Microsoft .NET Framework 3.5.1.  Required for Windows PowerShell Integrated Scripting Environment (ISE) and Out-GridView.  3. Install WinRM 2.0 CTP3. (Windows Remote Shell)  This is required if you want to take advantage of the remoting and back- ground jobs features.  4. Install Windows PowerShell 2. Starting point (ps2)
  • 5.  Set Execution Policy  Customise Console  Profile editing  Profile using Permission and Profiling
  • 6. Cmdlets Windows PowerShell (Cmdlet) Windows PowerShell (Alias) cmd.exe / COMMAND.COM (MS-DOS, Windows, OS/2, etc.) Description Get-Location gl, pwd cd Display the current directory/present working directory. Set-Location sl, cd, chdir cd, chdir Change the current directory Clear-Host cls, clear cls Clear the screen Copy-Item cpi, copy, cp copy Copy one or several files / a whole directory tree Get-Help help, man help Help on commands Remove-Item ri, del, erase, rmdir, rd, rm del, erase, rmdir, rd Delete a file / a directory Rename-Item rni, ren ren, rename Rename a file / a directory Move-Item mi, move, mv move Move a file / a directory to a new location Get-ChildItem gci, dir, ls dir List all files / directories in the (current) directory Write-Output echo, write echo Print strings, variables etc. to standard output Pop-Location popd popd Change the current directory to the directory most recently pushed onto the stack Push-Location pushd pushd Push the current directory onto the stack Set-Variable sv, set set Set the value of a variable / create a variable
  • 7.  Boolean: True or false condition.  Byte: An 8-bit unsigned whole number from 0 to 255, such as 32.  Char: A 16-bit unsigned whole number from 0 to 65,535. For example, 1,026.  Date: A calendar date, such as January 1, 2009.  Decimal: A 128-bit decimal value, such as 3.14159265.  Double: A double-precision 64-bit floating point number. In effect, this is another kind of decimal value but has a narrower range of values than a decimal.  Integer: A 32-bit signed whole number from –2,147,483,648 to 2,147,483,647, such as 152 or – 1839.  Long: A 64-bit signed whole number. This is like an integer but holds far more values, such as 9,233,372,036,854,775,807.  Object: Any kind of object.  Short: A 16-bit unsigned whole number. This is like an integer but holds far fewer values. It can only hold values from –32,768 to 32,767.  Single: A single-precision 32-bit floating point number. This is like a double but holds far fewer values, such as 20.3654.  String: A grouping of characters that most people just call text. Data types
  • 8.  $MyVariable  $AVariableWithANumber6  ${A variable with spaces}  ${A variable with special characters @#%%} Variables
  • 9.  $Error: An array of error objects representing the most recent errors.  $Host: Current host application for Windows PowerShell.  $Profile: Stores the full path to the Windows PowerShell user profile for the default shell.  $PID: Contains the process identifier of the Windows PowerShell process.  $PSUICulture: Stores the name of the UI culture currently in use.  $NULL: Contains NULL or empty value.  $False: Contains FALSE.  $True: Contains TRUE. Automatic variables
  • 10.  Concatenating  Escape characters  Multiline string  String functions String handling
  • 11.  Backslash:  Dollar sign: $  Dot: .  Pipe: |  Question mark: ?  Star: *  Plus sign: +  Open square bracket: [  Open parenthesis: (  Close parenthesis: )  Caret: ^ Regular expressions
  • 12.  Create functions  Calling functions  Passing arguments  Return values Functions
  • 13. Operator Meaning -eq Equal -ne Not equal -ine Not equal; not case sensitive (new in Windows PowerShell 2) -lt Less than -le Less than or equal -gt Greater than -ge Greater than or equal Operators
  • 14.  if statement  switch statement  for loop  foreach loop  while loop  do while loop  do until loop Control flow statements
  • 15.  Add (adds a Timespan value)  AddDays  AddHours  AddMilliseconds  AddMinutes  AddMonths  AddSeconds  AddTicks  AddYears DateTime
  • 16.  Arrays  Hash tables  Access elements Collections
  • 17.  Reading files  Writing file  Create files  Delete files  Copy / Rename / Move files File handling
  • 18.  Access system information  Disk info  Services  Event log  BIOS Windows Management Infrastructure (WMI)
  • 19.  Connect to SQL Server  Create SQL Command  Execute and capture data  Display data SQL Query Execution
  • 20.  Count errors  Throw exception  Handle exception  Write to log file  Write to Event log Exception handling
  • 21.  Message box  Installed drivers info  Path shrink  Convert to PDF  Send email  Hello Anna  Text to audio recording Cool stuff
  • 22.  Not allowing scripts to execute  Improperly using commas to separate parameters when calling a function  Not defining functions before using them  Forgetting that pipelines pass objects and not just strings  Not casting variables as a string  Making incorrect comparisons  Expending the pipeline to far  Not taking variable scope in account  Debugging without the debugger  Forgetting to use available .NET classes Common Mistakes
  • 23.  Windows PowerShell™ 2 For Dummies® by Steve Seguis  http://powershell.com/cs/  http://en.wikipedia.org/wiki/Windows_PowerShell  http://sandunangelo.blogspot.com/2010/02/introduction-to- powershell-scripting.html References

Editor's Notes

  • #5: Script pane Output pane Command pane