Wsv406 Advanced Automation Using Windows Power Shell2.0

30

description

Atlanta TechEd 2011 talk

Transcript of Wsv406 Advanced Automation Using Windows Power Shell2.0

Page 1: Wsv406 Advanced Automation Using Windows Power Shell2.0
Page 2: Wsv406 Advanced Automation Using Windows Power Shell2.0

Advanced Automation UsingWindows PowerShell 2.0

WSV406

Jeffrey SnoverDistinguished EngineerMicrosoft

Dan HarmanSenior Program ManagerMicrosoft

Page 3: Wsv406 Advanced Automation Using Windows Power Shell2.0

Session Overview

Technical Level: 400Intended Audience: IT administrators and scripters

Learning Objectives:Learn about improvements to Windows PowerShell 2.0Understand how to use advanced scripting techniquesSee how PowerShell features work in common scenarios

Presentation Outline:Overview of new PowerShell 2.0 featuresAdvanced scripting techniques in depthGUI over PowerShell demoProduction scripting demoUniversal automation environment demo

Page 4: Wsv406 Advanced Automation Using Windows Power Shell2.0

Improvements in PowerShell 2.0Dozens of big features

RemotingPowerShell ISEAdvanced FunctionsBackground JobsRestricted SessionsTransactionsOut-GridViewScript DebuggingNew & Improved CmdletsHosting APIs

ModulesEventingSession PoolsLanguage EnhancementsWMI ImprovementsImproved AD AdapterPerformance ImprovementsScript InternationalizationParser API SupportMore…

Page 5: Wsv406 Advanced Automation Using Windows Power Shell2.0

PowerShell Architecture

User Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Manager

Managed Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Page 6: Wsv406 Advanced Automation Using Windows Power Shell2.0

PowerShell 2.0 Themes

Production Scripting

Universal Automation Environment

GUI over PowerShell

Language and Cmdlets

Page 7: Wsv406 Advanced Automation Using Windows Power Shell2.0

GUI Over PowerShell

Layering admin GUIs on top of PowerShellDrives consistency between CLI & GUIEnables agility in delivering new GUIsGuarantees automation of GUI commandsFacilitates GUI teaching command lineStandardizes access to managed elements

GUI over PowerShell

Page 8: Wsv406 Advanced Automation Using Windows Power Shell2.0

GUI Over PowerShell Features

User Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Manager

Managed Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Session Pooling

Thread Control

Hosting APIs

PowerShell ISE

Out-GridView

Page 9: Wsv406 Advanced Automation Using Windows Power Shell2.0

demo

GUI Over PowerShell

Dan HarmanSenior Program ManagerWindows PowerShell

Page 10: Wsv406 Advanced Automation Using Windows Power Shell2.0

Production Scripting

Scripts are:Easy to useEasy to shareEasy to supportSafe to operate

Production Scripting

Page 11: Wsv406 Advanced Automation Using Windows Power Shell2.0

Production Scripting Features

User Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Manager

Managed Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Advanced Functions

Debugger Enhancements

Restricted Language

Modules

Transactions

Advanced Functions

Native Code

Page 12: Wsv406 Advanced Automation Using Windows Power Shell2.0

Advanced Functions

Gives the power of authoring custom cmdlets to IT prosWrite PowerShell cmdlets using script instead of compiled codeEnables consistent syntax and semantics between functions & cmdletsEvolution of function syntax from PowerShell 1.0Near parity with .NET cmdlet capabilities

Cmdlet attributes-SupportsShouldProcess-ConfirmImpact { Low | Medium | High }

$PSCmdlet similar to 'this' in C#$PSCmdlet.ShouldProcess("Target", "Action")$PSCmdlet.ShouldContinue("Query", "Caption")

Support inline help or external PSMAML help

Parameter attributesRangeLengthNot NullNot Null or EmptyPatternSetCountScript

Page 13: Wsv406 Advanced Automation Using Windows Power Shell2.0

demo

Production ScriptingAdvanced Functions

Jeffrey SnoverDistinguished EngineerWindows PowerShell

Page 14: Wsv406 Advanced Automation Using Windows Power Shell2.0

demo

Production ScriptingModules

Dan HarmanSenior Program ManagerWindows PowerShell

Page 15: Wsv406 Advanced Automation Using Windows Power Shell2.0

Universal Automation Environment

Interactive or programmaticIn the foreground or backgroundLocal or remoteSingle machine or multiple machinesSynchronous or asynchronousIn restricted or unrestricted environmentsWide range of authentication mechanismsSimple scripting to systems programming

Universal Automation Environment

Page 16: Wsv406 Advanced Automation Using Windows Power Shell2.0

Automation Environment Features

User Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Manager

Managed Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Background Jobs

Restricted Sessions

Mobile Object Model

Eventing

Remoting

Page 17: Wsv406 Advanced Automation Using Windows Power Shell2.0

Remoting Scenarios

1:Many (fan-out): Large Scale AutomationSend the script to remote machinesSelect properties - allows client to specify which properties to returnThrottling - limits the number of concurrent operationsJob support - runs commands in the background on client

1:1 (interactive): Secure Telnet ReplacementCmdlet equivalent of Remote DesktopInteract with a remote machine as if it were localNo Invoke-Command requiredIdeal for troubleshooting a remote machine

Many:1 (fan-in): Delegated Administration & HostingHosting model for web servicesNo tools installation required on clientConstrained session environment (cmdlets, parameters, language)

Page 18: Wsv406 Advanced Automation Using Windows Power Shell2.0

demo

Universal Automation EnvironmentRemoting

Jeffrey SnoverDistinguished EngineerWindows PowerShell

Page 19: Wsv406 Advanced Automation Using Windows Power Shell2.0

demo

Universal Automation EnvironmentBackground Jobs

Dan HarmanSenior Program ManagerWindows PowerShell

Page 20: Wsv406 Advanced Automation Using Windows Power Shell2.0

Language and Cmdlets

Responding to community feedbackEnhance the languageImprove the engineProvide more built-in cmdlets

Language and Cmdlets

Page 21: Wsv406 Advanced Automation Using Windows Power Shell2.0

Language and Cmdlets

User Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Manager

Managed Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

ImprovedObject Adapters

LanguageEnhancements

New Cmdlets

WMI++

Page 22: Wsv406 Advanced Automation Using Windows Power Shell2.0

Over 100 New Built-In CmdletsHundreds more from partners

ModulesExport-ModuleMemberGet-ModuleImport-ModuleNew-ModuleNew-ModuleManifestRemove-ModuleTest-ModuleManifest

EventingGet-EventGet-EventSubscriberNew-EventRegister-EngineEventRegister-ObjectEventRemove-EventUnregister-EventWait-Event

WS-ManConnect-WSManDisable-WSManCredSSPDisconnect-WSManEnable-WSManCredSSPGet-WSManCredSSPGet-WSManInstanceInvoke-WSManActionNew-WSManInstanceNew-WSManSessionOptionRemove-WSManInstanceSet-WSManInstanceSet-WSManQuickConfigTest-WSMan

TransactionsComplete-TransactionGet-TransactionStart-TransactionUndo-TransactionUse-Transaction

DebuggingDisable-PSBreakpointEnable-PSBreakpointGet-PSBreakpointGet-PSCallStackRemove-PSBreakpointSet-PSBreakpoint

Type ConversionAdd-TypeConvertFrom-CsvConvertFrom-StringDataConvertTo-CsvConvertTo-Xml

DiagnosticsClear-EventLogExport-CounterGet-CounterGet-HotfixGet-WinEventImport-CounterLimit-EventLogNew-EventLogRemove-EventLogShow-EventLogWrite-EventLog

ComputersAdd-ComputerCheckpoint-ComputerDisable-ComputerRestoreEnable-ComputerRestoreGet-ComputerRestorePointRemove-ComputerReset-ComputerPasswordRestart-ComputerRestore-ComputerStop-ComputerTest-Connection

WMIInvoke-WMIMethodRegister-WMIEventRemove-WMIObjectSet-WMIInstance

OtherClear-HistoryDebug-ProcessExport-FormatDataGet-FormatDataGet-RandomImport-LocalizedDataOut-GridViewSelect-XmlSend-MailMessageSet-StrictModeStart-ProcessTest-ComputerSecureChannelUpdate-ListWait-Process

RemotingDisable-PSSessionConfigurationEnable-PSSessionConfigurationEnable-PSRemotingEnter-PSSessionExit-PSSessionExport-PSSessionGet-PSSessionGet-PSSessionConfigurationImport-PSSessionInvoke-CommandNew-PSSessionNew-PSSessionOptionNew-WebServiceProxyRegister-PSSessionConfigurationRemove-PSSessionSet-PSSessionConfiguration

Custom SessionsDisable-PSSessionConfigurationEnable-PSSessionConfigurationGet-PSSessionConfigurationNew-PSSessionOptionRegister-PSSessionConfigurationSet-PSSessionConfigurationUnregister-PSSessionConfiguration

Background JobsGet-JobReceive-JobRemove-JobStart-JobStop-JobWait-Job

Page 23: Wsv406 Advanced Automation Using Windows Power Shell2.0

16 New Partners in Windows 7 & WS08 R2Many active internal partners

Exchange Server • Windows Diagnostics • Server Manager • SQL Server • Active Directory • Failover Clustering • System Center Operations Manager • Windows Backup • Server Migration • System Center Virtual Machine Manager • Best Practices Analyzer • Active Directory Rights Management Services • Internet Information Services • Background Intelligent Transfer Service • System Center Data Protection Manager • Network Load Balancing • Remote Desktop Services • Group Policy • WS-Management • AppLocker • WMI

Page 24: Wsv406 Advanced Automation Using Windows Power Shell2.0

Windows PowerShell Community Resources

Team blog: http://blogs.msdn.com/PowerShellPowerShell Community: http://www.powershellcommunity.orgPowerShell Forum: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads Channel 9: http://channel9.msdn.com/tags/PowerShellWiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWikiScript Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspxCodePlex: http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershellSome good books

PowerShell in Action, 2nd Edition by Bruce Payettehttp://www.manning.com/payette2

Windows PowerShell Cookbook, 2nd Edition by Lee Holmes http://oreilly.com/catalog/9780596801519/

Professional Windows PowerShell Programming http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.html

PowerShell Comics! http://borntolearn.mslearn.net/comics/b/weblog/archive/2011/04/20/climbing-mt-powershell-comic-book-first-pages.aspx

Page 25: Wsv406 Advanced Automation Using Windows Power Shell2.0

Related ContentBreakout Sessions

WSV406 | Advanced Automation Using Windows PowerShell 2.0 WSV315 Windows PowerShell for Beginners WCL321 | Windows PowerShell Remoting: Definitely NOT Just for Servers WSV322 | Managing the Registry with Windows PowerShell 2.0WSV471-INT | Build Reusable Tools in Windows PowerShellWSV473-INT | Windows PowerShell 3.0: Why Wait? Get Next-Generation PowerShell…EXL321 | Microsoft Lync Server 2010: Administering Lync Server Deployment

Hands-on LabsWSV276-HOL Introduction to Windows PowerShell Fundamentals WSV371-HOL Advanced Windows PowerShell Scripting WSV378-HOL Server Management and Windows PowerShell V2

Product Demo Stations WSV 1 – Windows PowerShell and Server Management

Page 26: Wsv406 Advanced Automation Using Windows Power Shell2.0

Track Resources

Don’t forget to visit the Cloud Power area within the TLC (Blue Section) to see product demos and speak with experts about the Server & Cloud Platform solutions that help drive your business forward.

You can also find the latest information about our products at the following links:

Windows Azure - http://www.microsoft.com/windowsazure/

Microsoft System Center - http://www.microsoft.com/systemcenter/

Microsoft Forefront - http://www.microsoft.com/forefront/

Windows Server - http://www.microsoft.com/windowsserver/

Cloud Power - http://www.microsoft.com/cloud/

Private Cloud - http://www.microsoft.com/privatecloud/

Page 27: Wsv406 Advanced Automation Using Windows Power Shell2.0

Resources

www.microsoft.com/teched

Sessions On-Demand & Community Microsoft Certification & Training Resources

Resources for IT Professionals Resources for Developers

www.microsoft.com/learning

http://microsoft.com/technet http://microsoft.com/msdn

Learning

http://northamerica.msteched.com

Connect. Share. Discuss.

Page 28: Wsv406 Advanced Automation Using Windows Power Shell2.0

Complete an evaluation on CommNet and enter to win!

Page 29: Wsv406 Advanced Automation Using Windows Power Shell2.0

Scan the Tag to evaluate this session now on myTech•Ed Mobile

Page 30: Wsv406 Advanced Automation Using Windows Power Shell2.0

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.