1 / 30

Unleashing the Power: A Lap Around PowerShell 3.0

Unleashing the Power: A Lap Around PowerShell 3.0. Presented by Sarah Dutkiewicz Central Ohio Day of .NET 2012 December 8, 2012. Windows PowerShell 3.0 – System Requirements & Prerequisites.

caron
Download Presentation

Unleashing the Power: A Lap Around PowerShell 3.0

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. Unleashing the Power: A Lap Around PowerShell 3.0 Presented by Sarah Dutkiewicz Central Ohio Day of .NET 2012 December 8, 2012

  2. Windows PowerShell 3.0 – System Requirements & Prerequisites • Operating Systems: Windows 7 SP1, Windows Server 2008 R2 SP1, Windows Server 2008 SP2, Windows 8, Windows Server 2012 • For the Integrated Scripting Environment for PowerShell 3.0 to be installed on Windows Server 2008 R2 SP1, the ISE feature must be enabled before installing Windows Management Framework 3.0

  3. Downloading PowerShell 3.0 • PowerShell is part of the Windows Management Framework 3.0 suite. • 32-bit & 64-bit installers available. • Windows 8 & Windows Server 2012 already have PowerShell 3.0 installed. • For other supported operating systems, download PowerShell from: http://www.microsoft.com/en-us/download/details.aspx?id=34595

  4. Core Enhancements • Computer cmdlets • CSV cmdlets • Get-ChildItem • Get-Command • Get-Content • Get-History • Measure-Object • Security cmdlets • Select-Object • Select-String • Split-Path • Start-Process • Tee-Object • Test-Connection • Add-Member

  5. Supports .NET Framework 4.0 • Built on CLR 4.0 • Adds features/support for: • Networking • Parallel Computing • Management Extensibility Framework (MEF) • Application Compatibility and Deployment • Windows Workflow Foundation (WF) • Windows Communication Foundation (WCF)

  6. Show-Command with the console D

  7. Updatable Help • Help Files aren’t installed by default on Windows 8 and Windows Server 2012, which means a smaller starting footprint for PowerShell. • Help files are easily installed and updated with the Update-Helpcmdlet • No restart is required for updating Help documentation. • Save-Help cmdlet can download help files to a file share. • Developers can add support for updatable help to their custom modules. More in this Dev Center article.

  8. Automatic ForEach/Implicit ForEach D • No more need for the foreach { … $_ } notation when dealing with collections. • While this syntax is no longer needed, it is still supported. • You can now access properties collectively as $collectionname.propertyname rather than having to iterate through the collection. • This also works with methods and not just properties.

  9. Simplified Where D • Much like the automatic foreach, the where clause has been simplified and the where {…. $_ } notation is no longer needed. • The old syntax is still supported but no longer necessary. • You can now search a collection with propertynamecomparisonoperatorsearchcriteria

  10. Enhanced Tab Completion D • New underlying parser and abstract syntax tree • Includes midline tab completion and in-memory parsing tress • Completes cmdlets, parameters, parameter values, enumerations, .NET Framework types, COM objects, hidden directories

  11. New JSON, REST, & HTML Parsing Support D • New cmdlets added to the PowerShell Core include: • Invoke-RestMethod • Invoke-WebRequest • ConvertFrom-Json • ConvertTo-Json • Try these examples: • Reading the latest titles and published dates from my blog: • Invoke-RestMethod–Uri http://feeds.feedburner.com/codinggeekette | Format-List title, pubdate • Reading the categories at NewEgg: • $newegg = Invoke-WebRequesthttp://www.newegg.com • $newegg.Links | where class –eq “tier1” | select innertext | Get-Unique –AsString

  12. Sessions Improvements • Disconnected sessions on remote computers can be reconnected later without losing state. • Because of this, if a session disconnects due to network connectivity issues, the session can be resumed once network connectivity has been reestablished.

  13. Integrated Scripting Environment Improvements D • Intellisense • Show-Command window – for all installed modules • Unified Console Pane – combining Command and Output windows • Rich copy • Block copy • Snippets • New-IseSnippet • Get-IseSnippet • Import-IseSnippet • Brace matching • Code outlining • Auto save • Recent items • Workflows

  14. ISE Improvements (continued) D

  15. Workflows D • Remote monitoring of long-running tasks • Persistence • Robustness – failure recovery • Disconnect, reconnect, and run in disconnected sessions • Workflow Scheduling • Workflow execution and connection throttling

  16. Scheduled Jobs D • Now integrates with Task Scheduler • Run asynchronously in the background • Can be one-time or recurrent • Can respond to actions and events

  17. Scheduled Jobs Example Workflow Reset-Temp { $pathToTemp = "C:\Windows\Temp\*" Remove-Item -Recurse -Force -Path $pathToTemp Suspend-Workflow }

  18. Scheduled Jobs Example (continued) Reset-Temp -JobName CLEAR_TEMP -PSPersist:$true $startuptrigger = New-JobTrigger -AtStartup $weeklyTrigger = New-JobTrigger -Weekly -DaysOfWeek Monday -At 9am Register-ScheduledJob -Name ClearTemp -Trigger $startuptrigger,$weeklyTrigger { Import-Module PSWorkflow Resume-Job CLEAR_TEMP }

  19. Scheduled Jobs Example (continued) In Task Scheduler, Under: Task Scheduler Library/Microsoft/Windows/PowerShell/ScheduledJobs

  20. Autoloading Modules D • As long as the module is available, PowerShell 3.0 will automatically load a module once a cmdlet is invoked from it. • This example is showing the module list before installing PowerShell Web Access and then the module list afterwards. Invoking Install-WindowsFeature triggers the loading of more modules, as it is in the ServerManager module.

  21. PowerShell Web Access D • Ability to run PowerShell from a web browser • Prerequisites: • Windows Server 2012 • Deployment instructions: http://technet.microsoft.com/en-us/library/hh831611.aspx

  22. PowerShell Web Access Limitations • Some function keys unsupported, dependent on the browser. • Only top-level progress information is available; nested progress displays won’t appear. • Input color (foreground and background) cannot be changed. • Anything that writes to the Windows console won’t work, as It isn’t implemented by PSWA. • Any limitations from a remote PowerShell session (New-PSSession, Enter-PSSession) apply to PowerShell Web Access as well.

  23. Management OData IIS Extension • Another part of Windows Management Framework 3.0 • Allows clients to invoke PowerShell cmdlets remotely using a RESTful web service accessible via OData.

  24. PowerShell Web Service D • Requires Management Odata feature to be installed first • Requires Windows Server 2012 • Sample requires to be built on a non-express SKU of Visual Studio 2010 or Visual Studio 2012

  25. PowerShell Web Service Example D • Download sample from: http://code.msdn.microsoft.com/windowsdesktop/PswsRoleBasedPlugins-1c7a7ef1 • Sample includes: • PowerShell script to setup Management Odata • Visual Studio solution with sample C# code • PowerShell script to setup the environment and create the endpoint • Custom endpoint should be: http://localhost:7000/MODataSvc/Microsoft.Management.Odata.svc

  26. Microsoft Script Explorer for Windows PowerShell D • Helps find scripts from various repositories – including TechNet Script Center Repository, PoshCode, Bing Search Repository, and local or network file systems • Searches scripts, modules, snippets, and how-to guidance • Can search in large Focus Areas or drill down into searching by category (as shown right)

  27. Microsoft Script Explorer for Windows PowerShell Prerequisites D • Works on 32-bit and 64-bit platforms • Operating system requirements: Windows 7 SP1, Windows 8, Windows Server 2008 R2 SP1, Windows Server 2008 SP2, Windows Server 2012, Windows Vista SP2 • Additional Requirements: PowerShell ISE, .NET 3.5 SP1, .NET 4 (Standalone or Web Installer) • Download it from the Microsoft Download Center: http://www.microsoft.com/en-us/download/details.aspx?id=29101

  28. Resources • PowerShell 3.0 Quick Reference Guides • New V3 Language Features • Intellisense in Windows PowerShell ISE 3.0 • Basic installation guide for Windows PowerShell Web Access • TechNet Radio: The Scripting Guy’s Top 5 PowerShell 3.0 Tips and Tricks • PowerShell Magazine • Windows PowerShell Blog

  29. Contact Information • Twitter: @sadukie • Facebook: Sarah “sadukie” Dutkiewicz • LinkedIn: http://www.linkedin.com/profile/view?id=27521335 • Email: sarah@codinggeekette.com • Blog: http://codinggeekette.com

  30. Thanks to our AWESOME sponsors!

More Related