Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows PowerShell Introduction 1 Morgan Simonsen Ementor.

Similar presentations


Presentation on theme: "Windows PowerShell Introduction 1 Morgan Simonsen Ementor."— Presentation transcript:

1 Windows PowerShell Introduction 1 Morgan Simonsen morgan.simonsen@ementor.no Ementor

2 What Will We Cover? What is Windows PowerShell? How does Windows PowerShell work? How can I use Windows PowerShell? 2

3 Level 200 Helpful Experience Command line experience; cmd.exe, BASH etc. Command line experience; parameters, output etc. Scripting experience (PERL, VBScript, JScript) etc.) 3

4 Microsoft Products Providing Windows PowerShell Cmdlets Windows Vista Exchange Server 2007 Operations Manager 2007 Windows Server “Longhorn” Virtual Machine Manager Data Protection Manager “V2” 4

5 Why PowerShell? As companies scale-out; management becomes very hard Current technologies; VBScript, WMI, RDP PowerShell will provide a unified management experience 5

6 Admin Tools RoadmapScenarioTodayTomorrow PowerShell Benefits GUI Shell MMC MMC with snap-ins layered on PowerShell GUI-Cmd parity GUI-Cmd parity Auto script creation (V2) Auto script creation (V2) Command Shell CMDCMDPowerShell CMD and UNIX shell parity CMD and UNIX shell parity Command consistency Command consistency Namespaces as Drives (e.g. FS, Reg, WMI, AD, Certs, etc) Namespaces as Drives (e.g. FS, Reg, WMI, AD, Certs, etc) Command Scripting CMD scripting PowerShell Richer language Richer language Better text utilities Better text utilities COM Scripting WSH VBScript VBScript Jscript JscriptWSH VBScript VBScript Jscript Jscript Jscript (.net) PowerShell Richer language Richer language Object utilities Object utilities Common access to COM, XML,.NET, ADO, WMI, ADSI Common access to COM, XML,.NET, ADO, WMI, ADSI 6

7 Admin Development Model Try things out in an interactive shell Stitch things together with utilities Put the results in a script file –Realize that the tools are unsuitable and restart with a new set of tools Generalize (e.g., parameterize) Clean it up  production-quality Integrate into your environment Share with the community 7

8 Introducing Windows PowerShell New Windows command-line shell designed for system administrators Interactive prompt and scripting environment Built on.NET Common Language Runtime (CLR) and.NET Framework 8

9 PowerShell Design Goals Ease of use Consisency of syntax Ease of learning curve 9

10 How is PowerShell different? PS processes objects, not text Large set (>100) of built in commands with cosistent interface Common command parser Can run all existing utilities, tools Multiple commands without batch files (;) 10

11 Getting and installing PowerShell Microsoft Download site x86/x64 versions available Installation requirements: –Windows XP SP2, Windows Server 2003 SP1 or later versions of Windows –.NET Framework 2.0 11

12 Getting and installing PowerShell Continued WinXP, W2K3 Srv: Update.exe install Vista/W2K8 Srv:.msu (component based install) Install locations: –X86: %systemroot%\system32\WindowsPowerShell\V1.0 –X64: %systemroot%\system32\WindowsPowerShell\V1.0 %systemroot%\Syswow64\WindowsPowerShell\V1.0 12

13 Starting PowerShell Powershell.exe –powershell -psconsolefile sqlsnapin.psc1 –powershell -version 1.0 -nologo -inputformat text - outputformat XML –powershell -command {get-eventlog -logname security} –powershell -command "& {get-eventlog -logname security}” Start Menu 13

14 Cmdlets (Command-lets) Built-in, single-feature commands that manipulate objects in PS Small and simple, designed to be used together with other cmdlets (pipelining) Comes with built-in help (Get-Help) Use a Verb-Noun names (Get-Service, Set-Service) 14

15 MSH> get-mailbox –server “smbex01” VerbNoun Name Argument String CommandParameter Cmdlets (Command-lets) Structure Property Names Property Values Name Alias Server StorageQuota ---- ---- ------ ------------ Bob Kelly bobk smbex01 unlimited Kim Akers kima smbex01 unlimited 15

16 Cmdlet parameters Always identified by -, never /, -- or \ Supports concatenation: get-help -det Names can be omitted: get-help –name get-alias = get-help get-alias 16

17 Getting help in PS Get-Help cmdlet Get-Help eg. Get-Help Get-Command eg. Get-Help Get-Command –detailed eg. Get-Help Get-Command –full eg. Get-Help Get-Command -examples Get-Help about_signing 17

18 Getting help: The 4 Pillars of Discoverability 1.Get-Command 2.Get-Help and -? 3.Get-PSDrive 4.Get-Members 18

19 Processing Objects PS works with.NET Objects.NET Objects contain: –Data –Properties –Methods 19

20 Learning about objects Get-Member: displays information about.NET objects a cmdlet returns get-service | get-member 20

21 Formatting Output PS cmdlets never format data Format cmdlets format data –Format-List –Format-Table –Format-Custom –Format-Wide Every cmdlet has default formatting based on the format cmdlets, which you can override 21

22 Aliases PS has several aliases by default (dir, ls, cls, del etc) Display aliases: get-alias Create alias: set-alias gh Get-Help Delete alias: remove-item alias:gh 22

23 Some useful cmdlets Get-Command Get-Childitem Get-ChildItemProperty Get-Service Get-WMIObject Invoke-Item 23

24 Using Windows Programs PS can run all Windows programs Must be in path statement ($env:path) List: Get-Command *.exe Aliases do not support its namesake’s paramteres 24

25 Tab Completion PS support Tab completions for: –Cmdlet names –Registry paths –Filesystem paths –Certificate paths 25

26 Pipelining Cmdlets can be ”piped” together to form complex commands Output from one cmdlet move along the pipe to another cmdlet PS pipeline operator is | (pipe) 26

27 For More Information Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell http://blogs.msdn.com/PowerShell Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptce nter/hubs/msh.mspx http://www.microsoft.com/technet/scriptce nter/hubs/msh.mspx 27

28 Books about PS 28


Download ppt "Windows PowerShell Introduction 1 Morgan Simonsen Ementor."

Similar presentations


Ads by Google