Windows PowerShell  The Next Generation Command Line Scripting Phan Quoc Hien  B110077
Agenda <ul><li>Introduction </li></ul><ul><ul><li>What is Windows PowerShell? </li></ul></ul><ul><li>Using PowerShell </li...
Introduction What is PowerShell?
What is PowerShell <ul><li>Revolutionary new interactive shell and scripting language </li></ul><ul><ul><li>Based on .NET ...
Why? <ul><li>Try things out in an interactive shell </li></ul><ul><li>Stitch things together with utilities </li></ul><ul>...
Where ? <ul><li>Supported on Windows XP and above </li></ul><ul><li>Microsoft Products </li></ul><ul><ul><li>Exchange 2007...
Using PowerShell
How to start? <ul><li>PowerShell is a free download from Microsoft </li></ul><ul><li>Separate download for each windows ve...
The basics <ul><ul><li>Syntax:  verb-noun  –parameter   arguments </li></ul></ul><ul><ul><li>Always singular, parameters s...
The basics (cont’d) <ul><li>You can alias </li></ul><ul><ul><li>Set-Alias gps Get-Process </li></ul></ul><ul><li>Parameter...
Variables <ul><li>Not case-sensitive </li></ul><ul><li>Default value is $null </li></ul><ul><li>Cmdlets to manage variable...
Variables (cont’d) <ul><li>Types </li></ul><ul><ul><li>User created variables </li></ul></ul><ul><ul><li>Automatic variabl...
Aliases <ul><li>Alternate names for cmdlets </li></ul><ul><li>Cmdlets to manage aliases </li></ul><ul><ul><li>Export-Alias...
Conditional & Looping <ul><li>Conditional statements </li></ul><ul><ul><li>If </li></ul></ul><ul><ul><li>Switch </li></ul>...
Operators <ul><li>Comparison operators </li></ul><ul><ul><li>-ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -no...
Getting Help <ul><li>Get-Command </li></ul><ul><ul><li>Gets a list of all commands  </li></ul></ul><ul><li>Get-Help </li><...
Trusting Operations <ul><li>Commands with side-effects support: </li></ul><ul><ul><li>Whatif </li></ul></ul><ul><ul><ul><l...
Security is key for PowerShell <ul><li>By default, only interactive usage allowed </li></ul><ul><li>If you want to use scr...
Finding Data in Data Stores <ul><li>Data stores surfaced as “Drives” </li></ul><ul><ul><li>Filesystem, Registry, Alias, Ce...
 
Out-Thankyou PS C:> Thank you for your time and attention. Good luck in your PowerShell Adventures! PS C:>
Upcoming SlideShare
Loading in...5
×

NIIT ISAS Q5 Report - Windows PowerShell

1,233

Published on

Windows PowerShell

Published in: Self Improvement, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,233
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • INF210
  • 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • 10/02/11 11:24 MICROSOFT CONFIDENTIAL © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • Start NOW !
  • 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  • 10/02/11 11:24 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. Demo Get-PSDrive Show navigation in File System and Registry
  • NIIT ISAS Q5 Report - Windows PowerShell

    1. 1. Windows PowerShell The Next Generation Command Line Scripting Phan Quoc Hien B110077
    2. 2. Agenda <ul><li>Introduction </li></ul><ul><ul><li>What is Windows PowerShell? </li></ul></ul><ul><li>Using PowerShell </li></ul><ul><ul><li>How can I script with Windows PowerShell? </li></ul></ul><ul><li>PowerShell and .net </li></ul><ul><ul><li>How .net developers will benefit from PowerShell </li></ul></ul>
    3. 3. Introduction What is PowerShell?
    4. 4. What is PowerShell <ul><li>Revolutionary new interactive shell and scripting language </li></ul><ul><ul><li>Based on .NET </li></ul></ul><ul><ul><li>New set of built-in tools (+120) </li></ul></ul><ul><ul><li>Can continue to use current tools </li></ul></ul><ul><ul><li>Can continue to use current automation (COM) </li></ul></ul><ul><ul><li>Allows access to data stores as easy to access as file systems </li></ul></ul>
    5. 5. Why? <ul><li>Try things out in an interactive shell </li></ul><ul><li>Stitch things together with utilities </li></ul><ul><li>Put the results in a script file </li></ul><ul><li>Generalize </li></ul><ul><li>Clean it up  production-quality </li></ul><ul><li>Be more Productive </li></ul><ul><li>Secure by default </li></ul>
    6. 6. Where ? <ul><li>Supported on Windows XP and above </li></ul><ul><li>Microsoft Products </li></ul><ul><ul><li>Exchange 2007 </li></ul></ul><ul><ul><li>System Center (Family) 2007 </li></ul></ul><ul><ul><li>New Management Architecture based on PowerShell </li></ul></ul><ul><ul><li>Windows Server 2008 </li></ul></ul><ul><li>None Microsoft Products </li></ul><ul><ul><li>IBM WebSphere MQ 6 </li></ul></ul><ul><ul><li>VMWare InfrastructureToolkit </li></ul></ul>
    7. 7. Using PowerShell
    8. 8. How to start? <ul><li>PowerShell is a free download from Microsoft </li></ul><ul><li>Separate download for each windows version </li></ul>
    9. 9. The basics <ul><ul><li>Syntax: verb-noun –parameter arguments </li></ul></ul><ul><ul><li>Always singular, parameters starts with “ - ” </li></ul></ul><ul><li>Examples: </li></ul><ul><ul><li>> Get-Process –name ie* </li></ul></ul><ul><ul><li>> Get-Process ie* </li></ul></ul><ul><ul><li>> Get-Service </li></ul></ul><ul><ul><li>> Read-Host “Please Enter a number” </li></ul></ul>
    10. 10. The basics (cont’d) <ul><li>You can alias </li></ul><ul><ul><li>Set-Alias gps Get-Process </li></ul></ul><ul><li>Parameters can be positional </li></ul><ul><ul><li>gps –ProcessName notepad </li></ul></ul><ul><ul><li>gps notepad </li></ul></ul><ul><li>Many parameters can be wildcarded </li></ul><ul><ul><li>gps note* </li></ul></ul><ul><li>Partial parameter names allowed </li></ul><ul><ul><li>Gps –p notepad </li></ul></ul>
    11. 11. Variables <ul><li>Not case-sensitive </li></ul><ul><li>Default value is $null </li></ul><ul><li>Cmdlets to manage variables </li></ul><ul><ul><li>Clear-Variable </li></ul></ul><ul><ul><li>Get-Variable </li></ul></ul><ul><ul><li>New-Variable </li></ul></ul><ul><ul><li>Remove-Variable </li></ul></ul><ul><ul><li>Set-Variable </li></ul></ul>
    12. 12. Variables (cont’d) <ul><li>Types </li></ul><ul><ul><li>User created variables </li></ul></ul><ul><ul><li>Automatic variables </li></ul></ul><ul><ul><ul><li>Created by PowerShell to maintain its state </li></ul></ul></ul><ul><ul><ul><li>Cannot be modified </li></ul></ul></ul><ul><ul><ul><li>Examples: $PSHome, $$, $^, $?, etc </li></ul></ul></ul><ul><ul><li>Preference variables </li></ul></ul><ul><ul><ul><li>Created by PowerShell to store user preferences </li></ul></ul></ul><ul><ul><ul><li>Can be modified </li></ul></ul></ul><ul><ul><ul><li>Examples: $MaximumHistoryCount, etc </li></ul></ul></ul>
    13. 13. Aliases <ul><li>Alternate names for cmdlets </li></ul><ul><li>Cmdlets to manage aliases </li></ul><ul><ul><li>Export-Alias </li></ul></ul><ul><ul><li>Get-Alias </li></ul></ul><ul><ul><li>Import-Alias </li></ul></ul><ul><ul><li>New-Alias </li></ul></ul><ul><ul><li>Set-Alias </li></ul></ul><ul><li>Cannot take parameters </li></ul><ul><ul><li>Workaround: put the statement in a script and alias to that </li></ul></ul><ul><li>Example: Dir, ls, gcm, gci, etc </li></ul>
    14. 14. Conditional & Looping <ul><li>Conditional statements </li></ul><ul><ul><li>If </li></ul></ul><ul><ul><li>Switch </li></ul></ul><ul><li>l.ooping </li></ul><ul><ul><li>For </li></ul></ul><ul><ul><ul><li>For ($i=0;$i –le 10;$i++) {Write-Host $i} </li></ul></ul></ul><ul><ul><li>Foreach </li></ul></ul><ul><ul><ul><li>Used on a collection of items </li></ul></ul></ul><ul><ul><ul><li>Foreach ($name in $namesArray) { Write-Host $name } </li></ul></ul></ul><ul><ul><li>Do </li></ul></ul><ul><ul><ul><li>Do { Write-Host $i; $i++ } while ($i –le 10) </li></ul></ul></ul><ul><ul><ul><li>Do { Write-Host $i;$i++} Until ($i –lt 10) </li></ul></ul></ul><ul><ul><li>While </li></ul></ul><ul><ul><ul><li>While ($i –le 10) { Write-Host $i;$i++ } </li></ul></ul></ul>
    15. 15. Operators <ul><li>Comparison operators </li></ul><ul><ul><li>-ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -notcontains, -match, -notmatch </li></ul></ul><ul><li>Logical operators </li></ul><ul><ul><li>-or, -and, -xor, -not, ! </li></ul></ul><ul><li>Arithmetic operators </li></ul><ul><li>Assignment operators </li></ul>
    16. 16. Getting Help <ul><li>Get-Command </li></ul><ul><ul><li>Gets a list of all commands </li></ul></ul><ul><li>Get-Help </li></ul><ul><ul><li>Shows help for a given cmdlet </li></ul></ul><ul><li>Get-Member </li></ul><ul><ul><li>Gets members of an object </li></ul></ul><ul><li>Get-PSDrive </li></ul><ul><ul><li>Shows information stores in PowerShell </li></ul></ul><ul><li>About_Topics </li></ul><ul><ul><li>Get-Help about* </li></ul></ul>
    17. 17. Trusting Operations <ul><li>Commands with side-effects support: </li></ul><ul><ul><li>Whatif </li></ul></ul><ul><ul><ul><li>Stop-Service win* –WhatIf </li></ul></ul></ul><ul><ul><li>Confirm </li></ul></ul><ul><ul><ul><li>Stop-process S* -Confirm </li></ul></ul></ul><ul><ul><li>Verbose </li></ul></ul>
    18. 18. Security is key for PowerShell <ul><li>By default, only interactive usage allowed </li></ul><ul><li>If you want to use scripting, you need to change the ExecutionPolicy </li></ul><ul><li>Get-ExecutionPolicy / Set-ExecutionPolicy </li></ul><ul><li>PS1 files opened with Notepad by design </li></ul>
    19. 19. Finding Data in Data Stores <ul><li>Data stores surfaced as “Drives” </li></ul><ul><ul><li>Filesystem, Registry, Alias, Certs, Env, Functions, Variables, etc. </li></ul></ul><ul><ul><li>> Get-PSDrive </li></ul></ul><ul><ul><li>> dir HKLM:SOFTWAREMicrosoft </li></ul></ul><ul><li>Rich common semantics </li></ul><ul><ul><li>> Dir logs –Include *.txt –Exclude A* -Recurse </li></ul></ul><ul><li>Tab-Completion in all Drives </li></ul><ul><ul><li>> Dir HKLM:So<TAB>Mi<TAB> => HLKM:SoftwareMicrosoft </li></ul></ul><ul><li>Demo 1 : File System Navigation </li></ul><ul><li>Demo 2 : Registry Navigation </li></ul><ul><li>Demo 3 : Environment Variables Navigation </li></ul>
    20. 21. Out-Thankyou PS C:> Thank you for your time and attention. Good luck in your PowerShell Adventures! PS C:>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×