Advanced Windows Power Shell Scripting

  • View
    217

  • Download
    0

Embed Size (px)

Text of Advanced Windows Power Shell Scripting

  • 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