KEMBAR78
Powershell_Basics_Robin | PPTX
WINDOWS
POWERSHELL BASICS Robin Aggarwal
What Is PowerShell?
Windows PowerShell includes an interactive prompt and a scripting environment
Commands are object-based
Large set of built-in commands
All shell commands use the same parser
Windows PowerShell 2.0 is installed by default on Windows Server®
2008 R2 and Windows® 7
PowerShell Syntax
Name
Argument
Verb Noun String
PS> get-mailbox –server “smbex01”
Command Parameter
Name Alias Server StorageQuota
---- ---- ------ ------------
Bob Kelly bobk smbex01 unlimited
Kim Akers kima smbex01 unlimited
Property Names
Property Values
Demo: Getting starting with PowerShell
• Powershell Cmd-let[Console]
• Powershell ISE
• Get-Verb
• Getting Help
• Getting Members
Piping and the Pipeline
Cmdlet Filter Sort
Scenario 1
Get-Service| Where-Object {$_.Status –eq “Running”} | Sort-Object Name
Data Types
Shortcut Data Type
[datetime] Date or time
[string] String of characters
[char] Single character
[double] Double-precision floating number
[single] Single-precision floating number
[int] 32-bit integer
[boolean] True or false value
Demo: Variables, Operations and Types
• Creating variables
• Operations
• Using types
• Creating arrays
Powershell Scripts
PowerShell Scripts have the .ps1 extension
Run a Script
C:Scriptssample.ps1
This script will get files and folder stored in
$a = Get-ChildItem
.sample.ps1
Script Security Settings
• Restricted – No scripts can be run. Windows PowerShell can be
used only in interactive mode.
• AllSigned – Only scripts signed by a trusted publisher can be run.
• RemoteSigned – Downloaded scripts must be signed by a trusted
publisher before they can be run.
• Unrestricted – No restrictions; all Windows PowerShell scripts can
be run.
Demo: Working with scripts
• Creating PowerShell scripts
• Running scripts
More features[if time permits]
• Registry [HKLM:]
• Certificates [cert:]
• Environment Variable [env:]
• Variables [variable:]
• Aliases
• Functions
• Extending powershell -> cmdlets
Demo: if time permits
• Killing processes
• Sort examples
• Using .Net examples[int, string, datetime]
• Let us touch AZURE
Capabilities of Powershell?
• Lets write down

Powershell_Basics_Robin

  • 1.
  • 2.
    What Is PowerShell? WindowsPowerShell includes an interactive prompt and a scripting environment Commands are object-based Large set of built-in commands All shell commands use the same parser Windows PowerShell 2.0 is installed by default on Windows Server® 2008 R2 and Windows® 7
  • 3.
    PowerShell Syntax Name Argument Verb NounString PS> get-mailbox –server “smbex01” Command Parameter Name Alias Server StorageQuota ---- ---- ------ ------------ Bob Kelly bobk smbex01 unlimited Kim Akers kima smbex01 unlimited Property Names Property Values
  • 4.
    Demo: Getting startingwith PowerShell • Powershell Cmd-let[Console] • Powershell ISE • Get-Verb • Getting Help • Getting Members
  • 5.
    Piping and thePipeline Cmdlet Filter Sort Scenario 1 Get-Service| Where-Object {$_.Status –eq “Running”} | Sort-Object Name
  • 6.
    Data Types Shortcut DataType [datetime] Date or time [string] String of characters [char] Single character [double] Double-precision floating number [single] Single-precision floating number [int] 32-bit integer [boolean] True or false value
  • 7.
    Demo: Variables, Operationsand Types • Creating variables • Operations • Using types • Creating arrays
  • 8.
    Powershell Scripts PowerShell Scriptshave the .ps1 extension Run a Script C:Scriptssample.ps1 This script will get files and folder stored in $a = Get-ChildItem .sample.ps1
  • 9.
    Script Security Settings •Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode. • AllSigned – Only scripts signed by a trusted publisher can be run. • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run. • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
  • 10.
    Demo: Working withscripts • Creating PowerShell scripts • Running scripts
  • 11.
    More features[if timepermits] • Registry [HKLM:] • Certificates [cert:] • Environment Variable [env:] • Variables [variable:] • Aliases • Functions • Extending powershell -> cmdlets
  • 12.
    Demo: if timepermits • Killing processes • Sort examples • Using .Net examples[int, string, datetime] • Let us touch AZURE
  • 13.