Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Windows PowerShell - Billings .NET User Group - August 2009

2,349 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Windows PowerShell - Billings .NET User Group - August 2009

  1. 1. Windows PowerShell<br />John Clayton<br />http://codemonkeylabs.com/<br />
  2. 2. Next generation command line shell<br />Processes objects instead of plain text<br />Large set of built-in commands<br />Consistent command parser<br />Scripting language<br />Designed for managing .NET objects<br />Provides a consistent environment for using cmdlets<br />Supports complex tasks without making simple tasks more complex<br />What is it?<br />
  3. 3. Built on .NET<br />Underlying objects are .NET<br />Extensible via cmdlets, providers, & host applications<br />Targeted at IT professionals<br />Supported by the latest server products<br />An astonishing amount can be accomplished without any programming<br />TechNet Script Center has hundreds of resources<br />What is it? (cont.)<br />
  4. 4. Using Windows PowerShell<br />Prepare to be amazed<br />
  5. 5. All commands use a Verb-Noun syntax<br />Self-describing, discoverable environment<br />Tab expansion<br />Command aliases<br />Brings in native applications & utilities<br />Object pipeline<br />Formatting<br />Navigation<br />Filtering<br />Scripting<br />The Shell<br />
  6. 6. Get-Command<br />
  7. 7. Get-Command<br />
  8. 8. Get-Command<br />
  9. 9. Get-Help<br />
  10. 10. Get-PSDrive<br />
  11. 11. Get-Member<br />
  12. 12. Command Aliases<br />
  13. 13. Native Applications<br />
  14. 14. Object pipeline<br />
  15. 15. Formatting<br />
  16. 16. Navigation<br />
  17. 17. Navigation<br />
  18. 18. Navigation<br />
  19. 19. Filtering, Looping, & Selecting<br />
  20. 20. Scripting<br />
  21. 21. Scripting<br />
  22. 22. Scripting<br />
  23. 23. Scripting<br />
  24. 24. Extending Windows PowerShell<br />If built in it is not, make it you shall<br />
  25. 25. Creating Cmdlets<br />In a class library reference System.Management.Automation<br />Hint: It’s not in the GAC!<br />
  26. 26. Creating Cmdlets<br />In a class library reference System.Configuration.Install<br />
  27. 27. Creating Cmdlets<br />Add a class and build your cmdlet<br />
  28. 28. Creating Cmdlets<br />Add a class and build your snap-in<br />
  29. 29. Creating Cmdlets<br />From an administrative Visual Studio command prompt navigate to your output directory and install your assembly<br />Gotcha: On a 64-bit system you’ll need to use the 64-bit version of InstallUtil.exe<br />
  30. 30. Creating Cmdlets<br />Launch a new instance of PowerShell<br />View the registered snap-ins:<br />Get-PSSnapIn –Registered<br />Register the snap-in:<br />Add-PSSnapIn<br />
  31. 31. Creating Cmdlets<br />Export the current console:<br />Export-Console<br />Include the exported file in your project<br />Set it to always copy to the output directory<br />
  32. 32. Creating Cmdlets<br />In the project properties set the debug action to start powershell.exe<br />In the command line arguments specify your console export file using the –PSConsoleFileflag<br />
  33. 33. Creating Cmdlets<br />
  34. 34. Hosting PowerShell<br />Create a new windows forms application<br />Add a reference to System.Management.Automation and your snap-in project<br />
  35. 35. Hosting PowerShell<br />In the form use a RunspaceConfiguration instance to add your snap-in, then create and open the runspace<br />
  36. 36. Hosting PowerShell<br />Using the runspace create and invoke a pipeline<br />Remember that Get-Proc is returning a collection and not individual items!<br />
  37. 37. PowerShell 1.0<br />Included in Windows Server 2008<br />Separate download for Windows XP SP2, Windows Server 2003, & Windows Vista<br />PowerShell 2.0<br />Included in Windows 7 & Windows Server 2008 R2<br />RC available for Windows XP SP3, Windows Server 2003 SP2, Vista SP1, & Windows Server 2008<br />Where do I get it?<br />
  38. 38. http://blogs.msdn.com/PowerShell/<br />http://bit.ly/powershell-ebook<br />http://bit.ly/scriptcenter<br />http://bit.ly/poshtweet<br />http://bit.ly/easy-powershell<br />Resources<br />

×