Jeffrey Snover Partner Architect Microsoft Corporation ES24.

30
Using PowerShell to Create Manageable Web Services Jeffrey Snover Partner Architect Microsoft Corporation ES24

Transcript of Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Page 1: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Using PowerShell to Create Manageable Web Services

Jeffrey SnoverPartner ArchitectMicrosoft Corporation

ES24

Page 2: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Deliver great management (cheaply)? Satisfy the full range of Admins? Automate operation of LOTS of

heterogeneous stuff (including raw HW)? Enable users to SAFELY do their own

management? Integrate into my customer’s

management system?

When Building A WS, How Do I…?

Page 3: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

PowerShell V1 PowerShell V2 Managing

Raw Hardware and other OSes Single Machines Sets of Machines

Scalable remote administration

Agenda

Page 4: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Windows PowerShellNew command-line shell and scripting language

• As interactive and composable as BASH/KSH• As programmatic as Perl/Python/Ruby• As production oriented as AS400 CL/VMS DCL• Allows access to data stores as easy to access as filesystem

Page 5: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Universal Automation Environment

Automation FrameworksAutomation Frameworks

Automation Frameworks

Cmdlets

In-Proc, Local, RemoteRuntime Engines

In-Proc, Local, RemoteRuntime Engines

In-Proc, Local, RemoteRuntime Engines

Automation Platform (API)

ScriptingLanguage

Type Normalizers

Type Normalizers

Type Normalizers

Providers Events, Jobs, Transactions

Shells, ISEs, GUI s, Applications Universal• Interactive or programmatic• Wide range of OSes• Local or Remote• Single or Multi Machine• Synch or Asynch• Wide range of authentication mechanisms• .NET, native code, COM, WMI, ADSI, XML, ADO, WebServices, WSMAN, etc• Simple scripting to systems programming

Powered by a strong community

Page 6: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Writing Cmdlets

Demo

Page 7: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

PowerShell V2 Goals

Reduce the cost and effort to: Use PowerShell

Get, learn, share scripts Layer applications on PowerShell

GUI, web, workflow, etc. Manage anything/everything

Servers, clients, distributed systems, applications, web services, cloud services, raw HW, other OSes, everything

Using any and all mechanisms (WMI, .Net, native code, web services, WSMAN)

Page 8: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Who Does What?V1 V2

Developer •Cmdlets and/or providers• Help

•PowerShell cmdlets •Transaction support

PowerShell • CLI & API

• Rich language w/access to com, wmi, .Net, adsi, xml & ado

• Utilities to manipulate, format, import/export

• 129 Cmdlets

•Web service & workflow activities

•Richer language w/access to web services, unmanaged code, wsman

• Richer utilities including eventing, job control, remote execution

• 241 Cmdlets

•Graphical ISE to create/debug scripts

Users •Simple ad hoc scripts•Sophisticated production scripting

•Systems programming•Across multiple machines

Community • Write and share scripts • Write and Share Modules

V1 Scripts and Cmdlets run on PowerShell V2

Page 9: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

PowerShell V2 in Windows 7PowerShell V2 in Server Core

Announcing

Page 10: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Managing Raw HW and Other OSes

Management initiative driven by DMTF Platform independent, interoperable & industry

standard management solution CIM based standards for Server and Desktop management WS-Management (WSMAN)

ITConsole

ManagedPlatforms

WSMAN

Page 11: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Raw HW Management - Examples

Power control and boot control HW/ SW inventory Alerts and lifecycle events Config/manage BIOS Software and Firmware update Health monitoring

Page 12: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Hardware Sample Commands

Power Off Command

Invoke-WSManAction -CN $svr -cred $cred -port 16992 `-Auth digest CIM_ComputerSystem `–Action RequestStateChange `–SelectorSet @{Name="ManagedSystem"} `-valueSet @{RequestedState="3"}

Chassis Class Get-WSManInstance -CN $svr -cred $cred -port 16992 -Auth digest -enum CIM_Chassis

Chip Class Get-WSManInstance –CN $srv -cred $cred -port 16992 -Auth digest -enum CIM_Chip

Power On Command

Invoke-WSManAction -CN $svr -cred $cred -port 16992 `-Auth digest CIM_ComputerSystem `–Action RequestStateChange `–SelectorSet @{Name="ManagedSystem"} `-valueSet @{RequestedState=“2"}

Page 13: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Managing Raw Hardware & Other OSes

Demo

Page 14: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Fine Grain Control For Working Across The Web

New-WSManSessionOption [-NoEncryption ] [-OperationTimeout <0->] [-ProxyAccessType <ProxyAutoDetect | ProxyIEConfig |

ProxyNoProxyServer | ProxyWinHttpConfig>] [-ProxyAuthentication <Basic | Digest | Negotiate>] [-ProxyCredential <PSCredential>] [-SkipCACheck ] [-SkipCNCheck ] [-SkipRevocationCheck ] [-SPNPort <0->] [-UseUTF16 ]

Page 15: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Managing Single Machines

Remote WMI Remote Command/Script Execution Remote Background Jobs Remote Interactive Session BITS

Page 16: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

BITS

Background Intelligent

Utilizes only idle network bandwidth. Throttles usage to preserve the user’s interactive experience.

Admin schedulable bandwidth usage limits Prioritized transfers Peer Caching Resumable

Transfer HTTP/HTTPS & SMB downloads/uploads

Used by over 600 million users worldwide

Page 17: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Managing Single Machines

Demo

Page 18: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

WMI -ComputerName <string[]> -Throttle <int> -AsJob

PS> gwmi -CN (cat servers.txt) Win32_Bios -Throttle 64 | Select __Server, Name, Manufacturer, Version | ConvertTo-Html > BiosInventory.htm

PS> $job = gwmi -CN (cat servers.txt) Win32_Bios -Throttle 64 –AsJob PS> Wait-job $j # or go do something else PS> Receive-Job $j |

Select __Server, Name, Manufacturer, Version | ConvertTo-Html > BiosInventory.htm

Managing Sets Of Machines

Page 19: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Invoke-Command can run expressions, commands and/or ScriptBlocks In the foreground or background

-AsJob On one or more machines

-ComputerName <string[]> Over a LAN or a WAN

-SessionOption <SessionOption> In restricted or unrestricted environments

- -ConfigurationName <String> Using short or long connections

-Session <RemoteRunspaceInfo[]> Using impersonation or supplied credentials

-Credentials

Register-PSEvent –Action <ScriptBlock>

Managing Sets Of Machines

Page 20: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Customer admin experience across the Web Different customers & different roles

Access different commands Have different options on the same commands

Interactive & scripting On-the-fly generation of

“virtual” commands

Scalable Remote Administration

Page 21: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

New ISS extension module: WSMAN WSMan plugin – PowerShell

Exposes a Resource URI Creates a new Session for every user running

on an impersonated thread Startup script configures the Session

Language: Full, Restricted, None Commands External applications Scripts Providers

Details

Page 22: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Company1

[email protected] [email protected]

SMB2

[email protected] [email protected]

WW

Hosting Service – Data Farm

CoolLabs.com

Page 23: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

SMB2

WW

W

Runspace [email protected]

Runspace [email protected]

[email protected] [email protected]

Company1

[email protected]@Company2.com

Page 24: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Scalable Remote Administration

Demo

Page 25: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Remote Programming

Demo

Page 26: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Deliver great management (cheaply)? Satisfy the full range of Admins? Automate operation of LOTS of

heterogeneous stuff (including raw HW)? Enable users to SAFELY do their own

management?

When Building A WS, How Do I…?

Windows PowerShell V2

Page 27: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Q&A

Page 28: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

Evals & Recordings

Please fill

out your

evaluation for

this session at:

This session will be available as a recording at:

www.microsoftpdc.com

Page 29: Jeffrey Snover Partner Architect Microsoft Corporation ES24.

© 2008 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.

Page 30: Jeffrey Snover Partner Architect Microsoft Corporation ES24.