Getting started with PowerShell Scripting<br />Ravikanth C<br />
A lead engineer at Dell<br />SharePoint professional by day and PowerShell scripter at night<br />Blog at http://www.ravic...
What is PowerShell?<br />Getting started<br />Using PowerShell<br />Getting Help<br />Tools for the job<br />Learning reso...
Remote file explorer -> 698 lines of PowerShell<br />This is just one example..!<br />Show me the Power first.!<br />
The best shell scripting environment for Windows<br />A new scripting language<br />Replacement for a weak Windows command...
PowerShell is in version 2.0<br />Default on Windows 7 and Windows Server 2008<br />Part of Windows management framework d...
Console history, Intellisense for cmdlets, variables and parameters<br />Using PowerShell: Console<br />
Using PowerShell: ISE<br />
Using PowerShell: Cmdlets<br /><ul><li>Pronounced as command-let
A lightweight command
an instance of .NET framework classes
Use verb-noun pairs
Get-Verb to list all approved verbs</li></li></ul><li>Not case-sensitive<br />Default value is $null<br />Cmdlets to manag...
Types<br />User created variables<br />Automatic variables<br />Created by PowerShell to maintain its state<br />Cannot be...
Alternate names for cmdlets<br />Cmdlets to manage aliases<br />Export-Alias<br />Get-Alias<br />Import-Alias<br />New-Ali...
Conditional statements<br />If<br />Switch<br />l.ooping<br />For<br />For ($i=0;$i –le 10;$i++)  {Write-Host $i}<br />For...
Comparison operators<br />-ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -notcontains, -match, -notmatch<br />L...
Arrays<br />Collection of objects of the same type<br />$a = @( )<br />$a = “PowerShell”,”VBScript”<br />Hash Tables<br />...
Getting Help<br />Get-Command<br />Gets a list of all commands <br />Get-Help<br />Shows help for a given cmdlet<br />Get-...
Upcoming SlideShare
Loading in...5
×

Getting Started With PowerShell Scripting

4,837

Published on

This slide was used at @PSBUG or PowerShell Bangalore User Group UG meet. This shows some fundamentals about getting started with PowerShell scripting

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,837
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
296
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Getting Started With PowerShell Scripting"

  1. 1. Getting started with PowerShell Scripting<br />Ravikanth C<br />
  2. 2. A lead engineer at Dell<br />SharePoint professional by day and PowerShell scripter at night<br />Blog at http://www.ravichaganti.com/blog<br />Developer of<br />PSCodePlex<br />PSRemoteFileExplorer<br />Remote File Explorer PowerPack<br />BITS File Transfer PowerPack<br />Author of<br />Free eBook - Layman’s guide to PowerShell 2.0 remoting (Coming soon)<br />About me<br />
  3. 3. What is PowerShell?<br />Getting started<br />Using PowerShell<br />Getting Help<br />Tools for the job<br />Learning resources<br />Q & A<br />Agenda<br />
  4. 4. Remote file explorer -> 698 lines of PowerShell<br />This is just one example..!<br />Show me the Power first.!<br />
  5. 5. The best shell scripting environment for Windows<br />A new scripting language<br />Replacement for a weak Windows command-line<br />Default management / automation platform for all Microsoft products going forward<br />Object based<br />Built on top of .NET type system<br />Everything is an object<br />What is PowerShell?<br />
  6. 6. PowerShell is in version 2.0<br />Default on Windows 7 and Windows Server 2008<br />Part of Windows management framework download for Windows Server 2008, Vista, XP and Windows 2003<br />http://support.microsoft.com/kb/968929<br />Requires .NET 2.0 SP1 or later<br />Getting started<br />
  7. 7. Console history, Intellisense for cmdlets, variables and parameters<br />Using PowerShell: Console<br />
  8. 8. Using PowerShell: ISE<br />
  9. 9. Using PowerShell: Cmdlets<br /><ul><li>Pronounced as command-let
  10. 10. A lightweight command
  11. 11. an instance of .NET framework classes
  12. 12. Use verb-noun pairs
  13. 13. Get-Verb to list all approved verbs</li></li></ul><li>Not case-sensitive<br />Default value is $null<br />Cmdlets to manage variables<br />Clear-Variable<br />Get-Variable<br />New-Variable<br />Remove-Variable<br />Set-Variable<br />Using PowerShell: Variables<br />
  14. 14. Types<br />User created variables<br />Automatic variables<br />Created by PowerShell to maintain its state<br />Cannot be modified<br />Examples: $PSHome, $$, $^, $?, etc<br />Preference variables<br />Created by PowerShell to store user preferences<br />Can be modified<br />Examples: $MaximumHistoryCount, etc<br />Using PowerShell: Variables<br />
  15. 15. Alternate names for cmdlets<br />Cmdlets to manage aliases<br />Export-Alias<br />Get-Alias<br />Import-Alias<br />New-Alias<br />Set-Alias<br />Cannot take parameters<br />Workaround: put the statement in a script and alias to that<br />Example: Dir, ls, gcm, gci, etc<br />Using PowerShell: Aliases<br />
  16. 16. Conditional statements<br />If<br />Switch<br />l.ooping<br />For<br />For ($i=0;$i –le 10;$i++) {Write-Host $i}<br />Foreach<br />Used on a collection of items<br />Foreach ($name in $namesArray) { Write-Host $name }<br />Do<br />Do { Write-Host $i; $i++ } while ($i –le 10)<br />Do { Write-Host $i;$i++} Until ($i –lt 10)<br />While<br />While ($i –le 10) { Write-Host $i;$i++ }<br />Using PowerShell: Conditional & Looping<br />
  17. 17. Comparison operators<br />-ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, -notcontains, -match, -notmatch<br />Logical operators<br />-or, -and, -xor, -not, !<br />Arithmetic operators<br />Assignment operators<br />Using PowerShell: Operators<br />
  18. 18. Arrays<br />Collection of objects of the same type<br />$a = @( )<br />$a = “PowerShell”,”VBScript”<br />Hash Tables<br />Collection of key value pairs<br />$ hash = @{ }<br />$a = {“Name”=“PowerShell”; “IsHot”=$true}<br />Using PowerShell: Arrays & Hash Tables<br />
  19. 19. Getting Help<br />Get-Command<br />Gets a list of all commands <br />Get-Help<br />Shows help for a given cmdlet<br />Get-Member<br />Gets members of an object<br />Get-PSDrive<br />Shows information stores in PowerShell<br />About_Topics<br />Get-Help about*<br />
  20. 20. In PowerShell, there will be more than one way to do the same thing. For example<br />[System.Diagnostics.Process]::GetProcesses()<br />Get-Process<br />Understand execution policies<br />Use PowerShell profiles<br />Best practices<br />
  21. 21. PowerShell Console<br />PowerShell ISE<br />PowerGUI AdminConsole<br />PowerGUI ScriptEditor<br />PowerWF<br />PowerShell Plus<br />Tools for the job<br />
  22. 22. Getting started guide<br />PowerShell Learning center<br />Free PowerShell eBook<br />The scripting Guys blog<br />PowerScripting Podcast<br />@PSBUG on Twitter<br />Learning resources<br />
  1. A particular slide catching your eye?

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

×