Unleashing the Power: A Lap Around PowerShell 3.0

1,092 views

Published on

Presented at Central Ohio .NET Developers Group on May 23, 2013

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Unleashing the Power: A Lap Around PowerShell 3.0

  1. 1. UNLEASHING THE POWER:A LAP AROUND POWERSHELL 3.0SARAH DUTKIEWICZCLEVELAND TECH CONSULTINGSARAH@CLETECHCONSULTING.COM
  2. 2. AGENDA• System Requirements• Overview of New & Improved Features• Resources• BONUS Material : Cool PowerShell Tools for Devs
  3. 3. WINDOWS MANAGEMENT FRAMEWORK 3.0• Includes:• Windows PowerShell 3.0• WMI• WinRM• Management OData IIS Extension• Server Manager CIM ProviderDownload Here
  4. 4. SYSTEM REQUIREMENTS• Windows 8, Windows Server 2012 – built-in• Windows 7 Service Pack 1• Windows Server 2008 R2 SP1• Windows Server 2008 Service Pack 2
  5. 5. INSTALLATION NOTES• Requires Microsoft .NET Framework 4.0• The Integrated Scripting Environment (ISE) is an optional feature for serverSKUs.• For Windows Server 2008, the previous version of Windows ManagementFramework – which contains PowerShell 2.0 – must be installed first.
  6. 6. GETTING STARTED – CONSOLE/VERSION
  7. 7. BACKWARDS COMPATIBILITY• Windows PowerShell 3.0 is backward-compatible.• 2.0 syntax and functionality that were designed for 2.0 should work in 3.0 withoutchanges.
  8. 8. POWERSHELL WEB ACCESSACCESS YOUR COMPANY’S COMPUTERS VIA POWERSHELL IN A WEB BROWSER
  9. 9. POWERSHELL WEB ACCESS - LIMITATIONS• Double-hop issues when connecting to a second computer• Same limitations as a remote Windows PowerShell session• Commands that call Windows console APIs don’t work.• Anything that displays a GUI doesn’t work.• Tab Completion doesn’t work in NoLanguage sessions.• Allows only one remote connection per browser session
  10. 10. POWERSHELL WEB ACCESS – MORE LIMITATIONS• Persistent Windows PowerShell sessions – need to use –Job for long running tasks andto allow disconnection rather than log off• No nested progress displays• Input colors cannot be modified• Function keys may not work in the PowerShell app if they are reserved for browserfunctionality• More notes at: Use the Web-based PowerShell Console
  11. 11. WINDOWS POWERSHELL WEB ACCESS• Requires:• Windows Server 2012• IIS• .NET Framework 4.5• PowerShell 3.0
  12. 12. POWERSHELL WEB ACCESS – BROWSER SUPPORT• Internet Explorer (8 or higher)• Firefox (10.0.2)• Chrome for Windows (17.0.963.56m)• Safari for Windows (5.1.2)• Safari for Mac (5.1.2)
  13. 13. POWERSHELL WEB ACCESS – MOBILE SUPPORT• Minimally tested on:• Windows Phone 7 and 7.5• Google Android WebKit 3.1 Browser Android 2.2.1 (Kernel 2.6)• Apple Safari for iPhone operating system 5.0.1• Apple Safari for iPad 2 operating system 5.0.1
  14. 14. POWERSHELL WEB ACCESS – BROWSERREQUIREMENTS• Allow cookies from the Windows PowerShell Web Access gateway website.• Be able to open and read HTTPS pages.• Open and run websites that use JavaScript.
  15. 15. POWERSHELL WEB ACCESS - INSTALLATION• Via Features/Roles wizard through the Server Manager• Through PowerShell cmdlets• Detailed instructions available here: http://technet.microsoft.com/en-us/library/hh831611.aspx#BKMK_install
  16. 16. POWERSHELL WEB ACCESS – SET UP THE GATEWAY• Use Install-PswaWebApplication to configure Windows PowerShellWeb Access.• Use the –UseTestCertificate parameter only for internal testing
  17. 17. POWERSHELL WEB ACCESS – SETTING UP THEGATEWAY
  18. 18. POWERSHELL WEB ACCESS – CONFIGURESECURITY• Use cmdlets to help specify what users have access to what.• For demo purposes, we’re using:Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName *
  19. 19. POWERSHELL WEB ACCESS – LOG IN
  20. 20. POWERSHELL WEB ACCESS - VERSION
  21. 21. NEW FEATURES & IMPROVEMENTSEASIER SYNTAX, BETTER PERFORMANCE, MORE ROBUSTNESS, AND MORE!
  22. 22. IMPROVED WHERE AND FOREACH SYNTAX• Example: Get all processes where CPU is greater than 1002.0:Get-Process | where { $_.CPU –gt 100 }3.0:Get-Process | where CPU –gt 100
  23. 23. IMPROVED WHERE AND FOREACH SYNTAX• Example: Find all available “Microsoft.*” available modules and split their names2.0:Get-Module –ListAvailable | Where { $_.Name –like “Microsoft.*” } | Foreach {$_.Name.Split(“.”) }3.0:Get-Module –ListAvailable | Where Name –like “Microsoft.*” | Foreach Split “.”
  24. 24. MICROSOFT .NET FRAMEWORK 4.0 SUPPORT• Application Compatibility and Deployment• Managed Extensibility Framework• Parallel Computing• Networking• Windows Communication Foundation• Windows Workflow Foundation
  25. 25. SESSION IMPROVEMENTS – DISCONNECTEDSESSIONS• Persistent sessions saved on remote computer• No longer session-dependent• New cmdlets: Connect-PSSession, Disconnect-PSSession, and Receive-PSSession• New parameter InDisconnectedSession• Both client and server need to be running Windows PowerShell 3.0
  26. 26. HELP IMPROVEMENTS – UPDATABLE HELP• Updatable Help System• By default, help files for a module update no more than once a day• Windows 8 and Windows Server 2012 do not have help files as part of theirinstallationsUpdate-HelpSave-HelpSupporting Updatable Help
  27. 27. HELP IMPROVEMENTS – ENHANCED ONLINE HELP• Enhanced Online Help• Works well even when the help files aren’t installed on the computerGet-Help {cmdlet} –OnlineSupporting Online Help
  28. 28. SCHEDULED JOBS & TASK SCHEDULERINTEGRATION• Windows PowerShell jobs can now be background jobs managed by TaskScheduler.• PowerShell scheduled jobs run asynchronously.• Scheduled jobs can be one-time or recurrent.• New cmdlet set for scheduled jobs• See more at about_Scheduled_Jobs
  29. 29. LANGUAGE ENHANCEMENTS – NEW CORECMDLETS• Full list can be seen here: http://technet.microsoft.com/en-us/library/hh857339.aspx#BKMK_CHAR• Highlights include:• ConvertTo-Json & ConvertFrom-Json• Disable-ScheduledJob & Enable-ScheduledJob• Invoke-RestMethod & Invoke-WebRequest
  30. 30. IMPROVEMENTS TO EXISTING FUNCTIONALITY• Simplified syntax and new parameters include:• Get-ChildItem• Get-Command• Get-Content• Get-History• Select-Object• Select-String• Split-Path• Start-Process• Test-Connection
  31. 31. IMPROVEMENTS TO EXISTING FUNCTIONALITY• Certificate provider supports SSL certificates for web hosting• Support for credential• Persistent network drives• Alternate data streams in file system drives
  32. 32. ENHANCED TAB COMPLETION• Tab completion was written on a new parser• Better midline tab completion• Now completes:• Cmdlets• Parameters• Parameter Values• Enumerations• .NET Framework types• COM objects• Hidden directories• More!
  33. 33. MODULE AUTO-LOADING• Get-Command now looks at all installed modules rather than just the importedones.• Automatic import is triggered by Get-Command, Get-Help, or running a cmdletfrom the module• This auto-loading can be controlled with the$PSModuleAutoLoadingPreference preference variable
  34. 34. MODULE EXPERIENCE IMPROVEMENTS• Module logging for individual modules (LogPipelineExecutionDetails) and the new "Turn on Module Logging"Group Policy setting• Extended module objects that expose the values from the module manifest• New ExportedCommands property of modules, including nested modules, that combines commands of alltypes• Improved discovery of available (un-imported) modules, including allowing the Path and ListAvailableparameters in the same command• New DefaultCommandPrefix key in module manifests that avoids name conflicts without changing modulecode.
  35. 35. MODULE EXPERIENCE IMPROVEMENTS• Improved module requirements, including fully-qualified required modules withversion and GUID and automatic importing of required modules• Quieter, streamlined operation of the New-ModuleManifest cmdlet.• New Module parameter for #Requires• Improved Import-Module cmdlet with both MinimumVersion andRequiredVersion parameters.
  36. 36. SIMPLIFIED COMMAND DISCOVERY• Get-Command displays all commands from all installed modules.• Due to auto-loading, a module will automatically be loaded once a commandfrom that module is executed.• Show-Command also helps beginners learn commands.
  37. 37. IMPROVED LOGGING• Supports Event Tracing in Windows (ETW) logs• “Turn on Module Logging” now included as a Group Policy setting.• Parameter values appear in log details in the log properties.
  38. 38. FORMATTING & OUTPUT IMPROVEMENTS• Output redirection for all streams• Enhanced Update-Type cmdlet that adds types dynamically without ps1xml formatfiles• Word wrap in output• Default formatting of custom objects• PSCustomObject type• Support for discovering method overloads
  39. 39. SPECIAL CHARACTER HANDLING IMPROVEMENTS• The LiteralPath parameter appears now on most cmdlets that use Path –including Update-Help and Save-Help• Improved handling of backticks and square brackets in file names and paths
  40. 40. NEW CMDLET AND HOSTING APIS• Public AST APIs• APIs for• Pipeline paging• Nested pipelines• Runspace pools tab completion• Windows RT• Obsolete cmdlet attribute• Verb and Noun properties of the FunctionInfo object
  41. 41. PERFORMANCE IMPROVEMENTS• New language parser built on the Dynamic Runtime Language in .NET 4.0• Runtime script compilation• Engine reliability improvements• Changes to the Get-ChildItem algorithm to enhance performance, especiallywith searching network shares
  42. 42. NEW FEATURES IN WINDOWS POWERSHELL ISE• Snippets• Includes advanced functions and their parameters and for Do, While, If, Switch, andForEach keywords.• Make your own snippets and import snippets from modules.• Three cmdlets: New-IseSnippet, Get-IseSnippet and Import-IseSnippet.• Brace-matching, error indicators, code outlining• Options Window
  43. 43. NEW FEATURES IN WINDOWS POWERSHELL ISE• Console pane• Command pane + Output pane• Behaves similar to console• Intellisense• Syntax highlighting• Snippets• Brace-matching• Error indicators• Show Command window• Intellisense
  44. 44. NEW FEATURES IN WINDOWS POWERSHELL ISE• Update Windows PowerShell Help from the Help menu• Help Window- displays help from the help files on the computer, complementing theUpdatable Help feature.• Auto-save• Recent items list• Block copy• And more!
  45. 45. MICROSOFT SCRIPT EXPLORER
  46. 46. MICROSOFT SCRIPT EXPLORER• Was a great way to search for scripts as guides – similar to the All-In-OneCode Framework app for developers• Unfortunately, not well-adopted, so the service will be turned off effectiveJune 14, 2013• What to do with this being discontinued? See the PowerShell blog post:Microsoft Script Explorer: Next Steps
  47. 47. POWERSHELL WEB SERVICE
  48. 48. WINDOWS POWERSHELL WEB SERVICE• Enables an administrator to expose a set of PowerShell cmdlets as a RESTfulendpoint via OData• Allows cmdlets to be invoked by any platform that can work with ODatafeeds – Windows and non-Windows• Windows PowerShell role-based OData Web Service sample• Windows PowerShell basic OData Web Service sample
  49. 49. SETTING UP WINDOWS POWERSHELL WEBSERVICE – INSTALL SCRIPT
  50. 50. SETTING UP WINDOWS POWERSHELL WEBSERVICE – SETUP THE ENDPOINT
  51. 51. DEMO OF POWERSHELL WEB SERVICE• More on PowerShell cmdlets invocation through Management OData usingWCF client
  52. 52. RESOURCES• Windows PowerShell Script Center• Windows PowerShell Language Specification Version 3.0• Windows PowerShell for Developers• Windows PowerShell 3.0 SDK Sample Pack• Windows PowerShell Reference
  53. 53. BONUS MATERIAL : COOL POWERSHELL TOOLS FOR DEVS• StudioShell – exposes Visual Studio’s extensibility points in a simple manner• SeeShell – Data Visualization for PowerShell• Psake – a build automation tool• OData PowerShell Provider – mount OData feeds as drives in PowerShell• PoShRabbit – exposes RabbitMQ to PowerShell

×