unleashing the power: a lap around powershell 3.0

53
UNLEASHING THE POWER: A LAP AROUND POWERSHELL 3.0 SARAH DUTKIEWICZ CLEVELAND TECH CONSULTING [email protected]

Upload: sarah-dutkiewicz

Post on 19-May-2015

712 views

Category:

Technology


3 download

DESCRIPTION

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

TRANSCRIPT

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

UNLEASHING THE POWER: A LAP AROUND POWERSHELL 3.0

SARAH DUTKIEWICZ

CLEVELAND TECH CONSULTING

[email protected]

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

AGENDA

• System Requirements

• Overview of New & Improved Features

• Resources

• BONUS Material : Cool PowerShell Tools for Devs

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

WINDOWS MANAGEMENT FRAMEWORK 3.0

• Includes:

• Windows PowerShell 3.0

• WMI

• WinRM

• Management OData IIS Extension

• Server Manager CIM Provider

Download Here

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

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

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

INSTALLATION NOTES

• Requires Microsoft .NET Framework 4.0

• The Integrated Scripting Environment (ISE) is an optional feature for server

SKUs.

• For Windows Server 2008, the previous version of Windows Management

Framework – which contains PowerShell 2.0 – must be installed first.

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

GETTING STARTED – CONSOLE/VERSION

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

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 without

changes.

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

POWERSHELL WEB ACCESSACCESS YOUR COMPANY’S COMPUTERS VIA POWERSHELL IN A WEB BROWSER

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

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

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

POWERSHELL WEB ACCESS – MORE LIMITATIONS

• Persistent Windows PowerShell sessions – need to use –Job for long running tasks and

to 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 browser

functionality

• More notes at: Use the Web-based PowerShell Console

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

WINDOWS POWERSHELL WEB ACCESS

• Requires:

• Windows Server 2012

• IIS

• .NET Framework 4.5

• PowerShell 3.0

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

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)

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

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

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

POWERSHELL WEB ACCESS – BROWSER REQUIREMENTS

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

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

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

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

POWERSHELL WEB ACCESS – SET UP THE GATEWAY

• Use Install-PswaWebApplication to configure Windows PowerShell

Web Access.

• Use the –UseTestCertificate parameter only for internal testing

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

POWERSHELL WEB ACCESS – SETTING UP THE GATEWAY

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

POWERSHELL WEB ACCESS – CONFIGURE SECURITY

• Use cmdlets to help specify what users have access to what.

• For demo purposes, we’re using:

Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName *

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

POWERSHELL WEB ACCESS – LOG IN

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

POWERSHELL WEB ACCESS - VERSION

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

NEW FEATURES & IMPROVEMENTSEASIER SYNTAX, BETTER PERFORMANCE, MORE ROBUSTNESS, AND MORE!

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

IMPROVED WHERE AND FOREACH SYNTAX

• Example: Get all processes where CPU is greater than 100

2.0:

Get-Process | where { $_.CPU –gt 100 }

3.0:

Get-Process | where CPU –gt 100

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

IMPROVED WHERE AND FOREACH SYNTAX

• Example: Find all available “Microsoft.*” available modules and split their names

2.0:

Get-Module –ListAvailable | Where { $_.Name –like “Microsoft.*” } | Foreach {

$_.Name.Split(“.”) }

3.0:

Get-Module –ListAvailable | Where Name –like “Microsoft.*” | Foreach Split “.”

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

MICROSOFT .NET FRAMEWORK 4.0 SUPPORT

• Application Compatibility and Deployment

• Managed Extensibility Framework

• Parallel Computing

• Networking

• Windows Communication Foundation

• Windows Workflow Foundation

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

SESSION IMPROVEMENTS – DISCONNECTED SESSIONS

• 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

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

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 their

installations

Update-Help

Save-Help

Supporting Updatable Help

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

HELP IMPROVEMENTS – ENHANCED ONLINE HELP

• Enhanced Online Help

• Works well even when the help files aren’t installed on the computer

Get-Help {cmdlet} –Online

Supporting Online Help

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

SCHEDULED JOBS & TASK SCHEDULER INTEGRATION

• Windows PowerShell jobs can now be background jobs managed by Task

Scheduler.

• 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

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

LANGUAGE ENHANCEMENTS – NEW CORE CMDLETS

• 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

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

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

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

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

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

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!

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

MODULE AUTO-LOADING

• Get-Command now looks at all installed modules rather than just the imported

ones.

• Automatic import is triggered by Get-Command, Get-Help, or running a cmdlet

from the module

• This auto-loading can be controlled with the

$PSModuleAutoLoadingPreference preference variable

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

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 all

types

• Improved discovery of available (un-imported) modules, including allowing the Path and ListAvailable

parameters in the same command

• New DefaultCommandPrefix key in module manifests that avoids name conflicts without changing module

code.

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

MODULE EXPERIENCE IMPROVEMENTS

• Improved module requirements, including fully-qualified required modules with

version 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 and

RequiredVersion parameters.

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

SIMPLIFIED COMMAND DISCOVERY

• Get-Command displays all commands from all installed modules.

• Due to auto-loading, a module will automatically be loaded once a command

from that module is executed.

• Show-Command also helps beginners learn commands.

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

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.

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

FORMATTING & OUTPUT IMPROVEMENTS

• Output redirection for all streams

• Enhanced Update-Type cmdlet that adds types dynamically without ps1xml format

files

• Word wrap in output

• Default formatting of custom objects

• PSCustomObject type

• Support for discovering method overloads

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

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

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

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

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

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, especially

with searching network shares

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

NEW FEATURES IN WINDOWS POWERSHELL ISE

• Snippets

• Includes advanced functions and their parameters and for Do, While, If, Switch, and

ForEach 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

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

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

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

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 the

Updatable Help feature.

• Auto-save

• Recent items list

• Block copy

• And more!

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

MICROSOFT SCRIPT EXPLORER

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

MICROSOFT SCRIPT EXPLORER

• Was a great way to search for scripts as guides – similar to the All-In-One

Code Framework app for developers

• Unfortunately, not well-adopted, so the service will be turned off effective

June 14, 2013

• What to do with this being discontinued? See the PowerShell blog post:

Microsoft Script Explorer: Next Steps

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

POWERSHELL WEB SERVICE

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

WINDOWS POWERSHELL WEB SERVICE

• Enables an administrator to expose a set of PowerShell cmdlets as a RESTful

endpoint via OData

• Allows cmdlets to be invoked by any platform that can work with OData

feeds – Windows and non-Windows

• Windows PowerShell role-based OData Web Service sample

• Windows PowerShell basic OData Web Service sample

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

SETTING UP WINDOWS POWERSHELL WEB SERVICE – INSTALL SCRIPT

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

SETTING UP WINDOWS POWERSHELL WEB SERVICE – SETUP THE ENDPOINT

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

DEMO OF POWERSHELL WEB SERVICE

• More on PowerShell cmdlets invocation through Management OData using

WCF client

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

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

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

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