unleashing the power: a lap around powershell 3.0

30
Unleashing the Power: A Lap Around PowerShell 3.0 PRESENTED BY SARAH DUTKIEWICZ CENTRAL OHIO DAY OF .NET 2012 DECEMBER 8, 2012

Upload: caron

Post on 25-Feb-2016

61 views

Category:

Documents


2 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Unleashing the Power: A Lap Around PowerShell  3.0

Unleashing the Power: A Lap

Around PowerShell 3.0

PRESENTED BY SARAH DUTKIEWICZCENTRAL OHIO DAY OF .NET 2012

DECEMBER 8, 2012

Page 2: Unleashing the Power: A Lap Around PowerShell  3.0

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

Page 3: Unleashing the Power: A Lap Around PowerShell  3.0

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

Page 4: Unleashing the Power: A Lap Around PowerShell  3.0

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

Page 5: Unleashing the Power: A Lap Around PowerShell  3.0

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)

Page 6: Unleashing the Power: A Lap Around PowerShell  3.0

Show-Command with the console D

Page 7: Unleashing the Power: A Lap Around PowerShell  3.0

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-Help cmdlet• 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.

Page 8: Unleashing the Power: A Lap Around PowerShell  3.0

Automatic ForEach/Implicit ForEach

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.

D

Page 9: Unleashing the Power: A Lap Around PowerShell  3.0

Simplified Where

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 propertyname comparisonoperator searchcriteria

D

Page 10: Unleashing the Power: A Lap Around PowerShell  3.0

Enhanced Tab Completion

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

D

Page 11: Unleashing the Power: A Lap Around PowerShell  3.0

New JSON, REST, & HTML Parsing Support

New cmdlets added to the PowerShell Core include: Invoke-RestMethod Invoke-WebRequest ConvertFrom-Json ConvertTo-Json

D

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-WebRequest http://www.newegg.com $newegg.Links | where class –eq “tier1” | select innertext | Get-Unique –AsString

Page 12: Unleashing the Power: A Lap Around PowerShell  3.0

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.

Page 13: Unleashing the Power: A Lap Around PowerShell  3.0

Integrated Scripting Environment Improvements

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

D

Page 14: Unleashing the Power: A Lap Around PowerShell  3.0

ISE Improvements (continued) D

Page 15: Unleashing the Power: A Lap Around PowerShell  3.0

Workflows

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

D

Page 16: Unleashing the Power: A Lap Around PowerShell  3.0

Scheduled Jobs

Now integrates with Task Scheduler Run asynchronously in the background Can be one-time or recurrent Can respond to actions and events

D

Page 17: Unleashing the Power: A Lap Around PowerShell  3.0

Scheduled Jobs Example

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

Page 18: Unleashing the Power: A Lap Around PowerShell  3.0

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}

Page 19: Unleashing the Power: A Lap Around PowerShell  3.0

Scheduled Jobs Example (continued)

In Task Scheduler, Under: Task Scheduler Library/Microsoft/Windows/PowerShell/ScheduledJobs

Page 20: Unleashing the Power: A Lap Around PowerShell  3.0

Autoloading Modules 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.

D

Page 21: Unleashing the Power: A Lap Around PowerShell  3.0

PowerShell Web Access

Ability to run PowerShell from a web browser

Prerequisites: Windows Server 2012

Deployment instructions: http://technet.microsoft.com/en-us/library/hh831611.aspx

D

Page 22: Unleashing the Power: A Lap Around PowerShell  3.0

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.

Page 23: Unleashing the Power: A Lap Around PowerShell  3.0

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.

Page 24: Unleashing the Power: A Lap Around PowerShell  3.0

PowerShell Web Service

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

D

Page 25: Unleashing the Power: A Lap Around PowerShell  3.0

PowerShell Web Service Example

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

D

Page 26: Unleashing the Power: A Lap Around PowerShell  3.0

Microsoft Script Explorer for Windows PowerShell 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)

D

Page 27: Unleashing the Power: A Lap Around PowerShell  3.0

Microsoft Script Explorer for Windows PowerShell Prerequisites

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

D

Page 30: Unleashing the Power: A Lap Around PowerShell  3.0

Thanks to our

AWESOME sponsors!