1 / 28

Windows PowerShell Introduction

Windows PowerShell Introduction. Morgan Simonsen morgan.simonsen@ementor.no Ementor. 1. What Will We Cover?. What is Windows PowerShell? How does Windows PowerShell work? How can I use Windows PowerShell?. 2. Helpful Experience. Command line experience; cmd.exe, BASH etc.

rowa
Download Presentation

Windows PowerShell Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

  5. Why PowerShell? • As companiesscale-out; managementbecomesvery hard • Currenttechnologies; VBScript, WMI, RDP • PowerShell willprovide a unifiedmanagementexperience 5

  6. Admin Tools Roadmap 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-lineshelldesigned for system administrators • Interactive prompt and scripting environment • Builton .NET CommonLanguageRuntime (CLR) and .NET Framework 8

  9. PowerShell Design Goals • Easeofuse • Consisencyofsyntax • Easeoflearningcurve 9

  10. How is PowerShell different? • PS processesobjects, not text • Large set (>100) ofbuilt in commandswithcosistentinterface • Commoncommand parser • Can run all existingutilities, tools • Multiple commandswithoutbatch files (;) 10

  11. Getting and installing PowerShell • Microsoft Downloadsite • x86/x64 versionsavailable • Installationrequirements: • Windows XP SP2, Windows Server 2003 SP1 or later versionsof Windows • .NET Framework 2.0 11

  12. Getting and installing PowerShell Continued • WinXP, W2K3 Srv: Update.exeinstall • Vista/W2K8 Srv: .msu (componentbasedinstall) • 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 <parameters> • powershell-psconsolefile sqlsnapin.psc1 • powershell-version 1.0 -nologo -inputformat text -outputformat XML • powershell-command {get-eventlog-lognamesecurity} • powershell-command "& {get-eventlog-lognamesecurity}” • Start Menu 13

  14. Cmdlets (Command-lets) • Built-in, single-featurecommandsthatmanipulateobjects in PS • Small and simple, designed to be used togetherwithother cmdlets (pipelining) • Comeswithbuilt-inhelp (Get-Help) • Use a Verb-Nounnames (Get-Service, Set-Service) 14

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

  16. Cmdlet parameters • Alwaysidentified by -, never /, -- or \ • Supports concatenation:get-help <command> -det • Namescan be omitted:get-help –nameget-alias = get-helpget-alias 16

  17. Gettinghelp in PS • Get-Helpcmdlet • Get-Help <cmdlet>eg. Get-HelpGet-Commandeg. Get-HelpGet-Command –detailedeg. Get-HelpGet-Command –fulleg. Get-HelpGet-Command-examples • Get-Helpabout_signing 17

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

  19. ProcessingObjects • PS workswith .NET Objects • .NET Objectscontain: • Data • Properties • Methods 19

  20. Learningaboutobjects • Get-Member: displays informationabout .NET objects a cmdletreturnsget-service | get-member 20

  21. Formatting Output • PS cmdlets never format data • Format cmdlets format data • Format-List • Format-Table • Format-Custom • Format-Wide • Everycmdlet has default formatting basedonthe format cmdlets, whichyoucan override 21

  22. Aliases • PS has severalaliases by default (dir, ls, cls, del etc) • Display aliases:get-alias • Create alias:set-aliasghGet-Help • Delete alias:remove-itemalias:gh 22

  23. Someuseful 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 pathstatement($env:path) • List:Get-Command *.exe • Aliases do not support itsnamesake’sparamteres 24

  25. Tab Completion • PS support Tab completions for: • Cmdletnames • Registrypaths • Filesystem paths • Certificatepaths 25

  26. Pipelining • Cmdlets can be ”piped” together to form complexcommands • Output from onecmdletmovealongthe pipe to anothercmdlet • PS pipeline operator is | (pipe) 26

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

  28. Booksabout PS 28

More Related