Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ravikanth C.

Similar presentations


Presentation on theme: "Ravikanth C."— Presentation transcript:

1 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com Ravikanth C

2 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  A lead engineer at Dell  SharePoint professional by day and PowerShell scripter at night  Blog at http://www.ravichaganti.com/bloghttp://www.ravichaganti.com/blog  Developer of ◦ PSCodePlex ◦ PSRemoteFileExplorer ◦ Remote File Explorer PowerPack ◦ BITS File Transfer PowerPack  Author of ◦ Free eBook - Layman’s guide to PowerShell 2.0 remoting (Coming soon)

3 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  What is PowerShell?  Getting started  Using PowerShell  Getting Help  Tools for the job  Learning resources  Q & A

4 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Remote file explorer -> 698 lines of PowerShell  This is just one example..!

5 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  The best shell scripting environment for Windows ◦ A new scripting language ◦ Replacement for a weak Windows command-line  Default management / automation platform for all Microsoft products going forward  Object based ◦ Built on top of.NET type system ◦ Everything is an object DOS BatchPowerShell @echo off setLocal EnableDelayedExpansion set /a value=0 set /a sum=0 FOR /R %1 %I IN (*) DO ( set /a value=%~zI/1024 set /a sum=!sum!+!value! ) @echo Size is: !sum! k $size=0;Get-ChildItem C:\Scripts | % { $Size+=$_.Length}

6 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  PowerShell is in version 2.0  Default on Windows 7 and Windows Server 2008  Part of Windows management framework download for Windows Server 2008, Vista, XP and Windows 2003 ◦ http://support.microsoft.com/kb/968929 http://support.microsoft.com/kb/968929  Requires.NET 2.0 SP1 or later

7 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Console history, Intellisense for cmdlets, variables and parameters

8 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com

9 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Pronounced as command-let  A lightweight command  an instance of.NET framework classes  Use verb-noun pairs ◦ Get-Verb to list all approved verbs

10 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Not case-sensitive  Default value is $null  Cmdlets to manage variables ◦ Clear-Variable ◦ Get-Variable ◦ New-Variable ◦ Remove-Variable ◦ Set-Variable

11 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Types ◦ User created variables ◦ Automatic variables  Created by PowerShell to maintain its state  Cannot be modified  Examples: $PSHome, $$, $^, $?, etc ◦ Preference variables  Created by PowerShell to store user preferences  Can be modified  Examples: $MaximumHistoryCount, etc

12 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Alternate names for cmdlets  Cmdlets to manage aliases ◦ Export-Alias ◦ Get-Alias ◦ Import-Alias ◦ New-Alias ◦ Set-Alias  Cannot take parameters ◦ Workaround: put the statement in a script and alias to that  Example: Dir, ls, gcm, gci, etc

13 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Conditional statements ◦ If ◦ Switch  l.ooping ◦ For  For ($i=0;$i –le 10;$i++) {Write-Host $i} ◦ Foreach  Used on a collection of items  Foreach ($name in $namesArray) { Write-Host $name } ◦ Do  Do { Write-Host $i; $i++ } while ($i –le 10)  Do { Write-Host $i;$i++} Until ($i –lt 10) ◦ While  While ($i –le 10) { Write-Host $i;$i++ }

14 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Comparison operators ◦ -ne, -eq, -lt, -gt, -ge, -le, -like, -notlike, -contains, - notcontains, -match, -notmatch  Logical operators ◦ -or, -and, -xor, -not, !  Arithmetic operators  Assignment operators

15 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Arrays ◦ Collection of objects of the same type ◦ $a = @( ) ◦ $a = “PowerShell”,”VBScript”  Hash Tables ◦ Collection of key value pairs ◦ $ hash = @{ } ◦ $a = {“Name”=“PowerShell”; “IsHot”=$true}

16 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Get-Command ◦ Gets a list of all commands  Get-Help ◦ Shows help for a given cmdlet  Get-Member ◦ Gets members of an object  Get-PSDrive ◦ Shows information stores in PowerShell  About_Topics ◦ Get-Help about*

17 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  In PowerShell, there will be more than one way to do the same thing. For example ◦ [System.Diagnostics.Process]::GetProcesses() ◦ Get-Process  Understand execution policies  Use PowerShell profiles

18 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  PowerShell Console  PowerShell ISE  PowerGUI AdminConsole  PowerGUI ScriptEditor  PowerWF  PowerShell Plus

19 Email: Ravikanth@Ravichaganti.comTwitter: @RavikanthBlog: http://www.ravichaganti.com  Getting started guide Getting started guide  PowerShell Learning center PowerShell Learning center  Free PowerShell eBook Free PowerShell eBook  The scripting Guys blog The scripting Guys blog  PowerScripting Podcast PowerScripting Podcast  @PSBUG on Twitter @PSBUG on Twitter


Download ppt "Ravikanth C."

Similar presentations


Ads by Google