Advanced Windows Power Shell Scripting

Embed Size (px)

Citation preview

  • 8/2/2019 Advanced Windows Power Shell Scripting

    1/28

  • 8/2/2019 Advanced Windows Power Shell Scripting

    2/28

    Ibrahim Abdul RahimTest EngineerMicrosoft CorporationWSV402

    Dan HarmanProgram ManagerMicrosoft Corporation

  • 8/2/2019 Advanced Windows Power Shell Scripting

    3/28

    Improvements in PowerShell 2.0Dozens of big features, thousands of fixes

    Remoting

    PowerShell ISE

    Advanced Functions

    Background JobsRestricted Sessions

    Transactions

    Out-GridView

    Script DebuggingNew & Improved Cmdlets

    Hosting APIs

    Modules

    Eventing

    Session Pools

    Language EnhancementsWMI Improvements

    Improved AD Adapter

    Performance Improvements

    Script InternationalizationParser API Support

    More

  • 8/2/2019 Advanced Windows Power Shell Scripting

    4/28

    PowerShell Architecture

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Manager

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XML

    ADO

    ADSI

    Native Commands

  • 8/2/2019 Advanced Windows Power Shell Scripting

    5/28

    PowerShell 2.0 Themes

    Production Scripting

    Automation Environment

    GUI over PowerShell

    Language and Cmdlets

  • 8/2/2019 Advanced Windows Power Shell Scripting

    6/28

    Production Scripting

    Scripts are:Easy to use

    Easy to share

    Easy to supportSafe to operate

    Production Scripting

  • 8/2/2019 Advanced Windows Power Shell Scripting

    7/28

    Production Scripting Features

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Manager

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XML

    ADO

    ADSI

    Native Commands

    Advanced Functions

    Debugger Enhancements

    Restricted Language

    Modules

    Transactions

    Advanced Functions

    Native Code

  • 8/2/2019 Advanced Windows Power Shell Scripting

    8/28

    Production ScriptingDan HarmanProgram Manager

    Windows PowerShell

  • 8/2/2019 Advanced Windows Power Shell Scripting

    9/28

    Universal Automation Environment

    Interactive or programmatic

    In the foreground or background

    Local or remote

    Single machine or multiple machines

    Synchronous or asynchronousIn restricted or unrestricted environments

    Wide range of authentication mechanisms

    Simple scripting to systems programming

    Universal Automation

  • 8/2/2019 Advanced Windows Power Shell Scripting

    10/28

    Automation Environment Features

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Manager

    ManagedElements

    Cmdlets

    WMI

    COM

    .NET

    XML

    ADO

    ADSI

    Native Commands

    Background Jobs

    Restricted Sessions

    Mobile Object Model

    Eventing

    Remoting

  • 8/2/2019 Advanced Windows Power Shell Scripting

    11/28

    Remoting Scenarios

    1:Many (fan-out): Large Scale AutomationSend the script to remote machines

    Select properties allows client to specify which properties to return

    Throttling limits the number of concurrent operations

    Job support runs commands in the background on client

    1:1 (interactive): Secure Telnet ReplacementCmdline equivalent of Remote Desktop

    Interact with a remote machine as if it were local

    No Invoke-Command required

    Ideal for troubleshooting a remote machine

    Many:1 (fan-in): Delegated Administration & HostingHosting model for web services

    No tools installation required on client

    Constrained session environment (cmdlets, parameters, language)

  • 8/2/2019 Advanced Windows Power Shell Scripting

    12/28

    Universal Automation EnvironmentIbrahim Abdul RahimTest Engineer

    Windows PowerShell

  • 8/2/2019 Advanced Windows Power Shell Scripting

    13/28

    GUI over PowerShell

    Layering admin GUIs on top of PowerShellDrives consistency between CLI & GUI

    Enables agility in delivering new GUIs

    Guarantees automation of GUI commands

    Facilitates GUI teaching command line

    Standardizes access to managed elements

    GUI over PowerShell

  • 8/2/2019 Advanced Windows Power Shell Scripting

    14/28

    GUI over PowerShell Features

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Manager

    ManagedElements

    Cmdlets

    WMICOM

    .NET

    XML

    ADO

    ADSI

    Native Commands

    Session Pooling

    Thread Control

    Hosting APIs

    PowerShell ISE

    Out-GridView

  • 8/2/2019 Advanced Windows Power Shell Scripting

    15/28

    GUI over PowerShellIbrahim Abdul RahimTest Engineer

    Windows PowerShell

  • 8/2/2019 Advanced Windows Power Shell Scripting

    16/28

    Language and Cmdlets

    Responding to community feedbackEnhance the language

    Improve the engine

    Provide more built-in cmdlets

    Language and Cmdlets

  • 8/2/2019 Advanced Windows Power Shell Scripting

    17/28

    Language and Cmdlets

    UserExperience

    Shell

    Language

    Debugger

    Engine

    APIs

    Execution Context

    Object Manager

    ManagedElements

    Cmdlets

    WMICOM

    .NET

    XML

    ADO

    ADSI

    Native Commands

    Improved

    Object Adapters

    Language

    Enhancements

    New Cmdlets

    WMI++

  • 8/2/2019 Advanced Windows Power Shell Scripting

    18/28

    RemotingDisable-PSSessionConfigurationEnable-PSRemotingEnable-PSSessionConfigurationEnter-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

    TransactionsComplete-TransactionGet-TransactionStart-TransactionUndo-TransactionUse-Transaction

    DebuggingDisable-PSBreakpointEnable-PSBreakpointGet-PSBreakpoint

    Get-PSCallStackRemove-PSBreakpointSet-PSBreakpoint

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

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

    Write-EventLog

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

    WMIInvoke-WMIMethodRegister-WMIEventRemove-WMIObjectSet-WMIInstance

    OtherClear-HistoryDebug-Process

    Export-FormatDataGet-FormatDataGet-RandomImport-LocalizedDataOut-GridViewSelect-XmlSend-MailMessageSet-StrictModeStart-ProcessTest-ComputerSecureChannelUpdate-ListWait-Process

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

    EventingGet-Event

    Get-EventSubscriberNew-EventRegister-EngineEventRegister-ObjectEventRemove-EventUnregister-EventWait-Event

    WS-ManConnect-WSManDisable-WSManCredSSP

    Disconnect-WSManEnable-WSManCredSSPGet-WSManCredSSPGet-WSManInstanceInvoke-WSManActionNew-WSManInstanceNew-WSManSessionOptionRemove-WSManInstanceSet-WSManInstanceSet-WSManQuickConfigTest-WSMan

    Over 100 New Built-In CmdletsHundreds more from partners

  • 8/2/2019 Advanced Windows Power Shell Scripting

    19/28

    Example: Virtual Machine Self-Service Portal

    Dan HarmanProgram Manager

    Windows PowerShell

  • 8/2/2019 Advanced Windows Power Shell Scripting

    20/28

    16 Partners in Windows 7 & WS08 R270+ active internal partners

    Exchange Server Windows Diagnostics ServerManager SQL Server Active Directory FailoverClustering System Center Operations Manager Windows Backup Server Migration System Center

    Virtual Machine Manager Best Practices Analyzer Active Directory Rights Management Services Internet InformationServicesBackground IntelligentTransfer Service System Center Data Protection

    Manager Network Load Balancing RemoteDesktopServices GroupPolicyWS-Management

    AppLockerWMI

  • 8/2/2019 Advanced Windows Power Shell Scripting

    21/28

    Community Resources

    Newsgroup: Microsoft.Public.Windows.PowerShell

    Team blog: http://blogs.msdn.com/PowerShell

    PowerShell Community: http://www.powershellcommunity.org

    Channel 9: http://channel9.msdn.com/tags/PowerShell

    Wiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki

    Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

    CodePlex: http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell

    Books

    PowerShell in Action by Bruce Payette

    http://manning.com/powershell

    Windows PowerShell Cookbook by Lee Holmeshttp://www.oreilly.com/catalog/9780596528492/index.html

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

    Many others

    http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.windows.powershellhttp://blogs.msdn.com/PowerShellhttp://www.powershellcommunity.org/http://channel9.msdn.com/tags/PowerShellhttp://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWikihttp://www.microsoft.com/technet/scriptcenter/hubs/msh.mspxhttp://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershellhttp://manning.com/powershellhttp://www.oreilly.com/catalog/9780596528492/index.htmlhttp://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.htmlhttp://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.htmlhttp://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.htmlhttp://www.wrox.com/WileyCDA/WroxTitle/productCd-0470173939.htmlhttp://www.oreilly.com/catalog/9780596528492/index.htmlhttp://manning.com/powershellhttp://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershellhttp://www.microsoft.com/technet/scriptcenter/hubs/msh.mspxhttp://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWikihttp://channel9.msdn.com/tags/PowerShellhttp://www.powershellcommunity.org/http://blogs.msdn.com/PowerShellhttp://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.windows.powershell
  • 8/2/2019 Advanced Windows Power Shell Scripting

    22/28

  • 8/2/2019 Advanced Windows Power Shell Scripting

    23/28

    www.microsoft.com/teched

    Sessions On-Demand & Community

    http://microsoft.com/technet

    Resources for IT Professionals

    http://microsoft.com/msdn

    Resources for Developers

    www.microsoft.com/learning

    Microsoft Certification and Training Resources

    www.microsoft.com/learning

    Microsoft Certification & Training Resources

    Resources

    http://www.microsoft.com/techedhttp://microsoft.com/technethttp://microsoft.com/msdnhttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://www.microsoft.com/learninghttp://microsoft.com/msdnhttp://microsoft.com/technethttp://www.microsoft.com/teched
  • 8/2/2019 Advanced Windows Power Shell Scripting

    24/28

    Related Content

    Breakout SessionsDAT314 Microsoft SQL Server Automation on Steroids, Including PowerShell SupportSIA313 Managing Active Directory Identities with Active Directory PowerShellWCL314 Windows PowerShell for the Windows 7 Enterprise ClientWSV304 Deploying and Managing Scalable Web Server Farms with IIS 7.0WSV325 Windows PowerShell: Tips from the Expert

    Interactive Theater SessionsUNC03-INT Mastering Exchange Management with the Exchange Management Shell

    Hands-on LabsWSV08-HOL Introduction to Windows PowerShell FundamentalsWSV03-HOL Advanced Windows PowerShell ScriptingWSV19-HOL Windows Server 2008 R2: Server Management and PowerShell V2

    Birds of a Feather Sessions

    BOF01 Should Developers Care about Windows PowerShell?BOF61 Practical PowerShell: Best Practices from the Field

  • 8/2/2019 Advanced Windows Power Shell Scripting

    25/28

    Windows Server Resources

    Make sure you pick up yourcopy of Windows Server 2008R2 RC from the MaterialsDistribution Counter

    Learn More about Windows Server 2008 R2:www.microsoft.com/WindowsServer2008R2

    Technical Learning Center (Orange Section):Highlighting Windows Server 2008 and R2 technologies Over 15 booths and experts from Microsoft and our partners

    http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2
  • 8/2/2019 Advanced Windows Power Shell Scripting

    26/28

    Help make Windows Server and System Center better

    User Experience Studies

    Participate in user experience studies while at TechEd

    Sign up on Twitter @MS_ITPro_UX

    http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2
  • 8/2/2019 Advanced Windows Power Shell Scripting

    27/28

    Complete an

    evaluation onCommNet and

    enter to win!

    http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2
  • 8/2/2019 Advanced Windows Power Shell Scripting

    28/28

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

    http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2http://www.microsoft.com/WindowsServer2008R2