Title of Presentation

whoasunInternet και Εφαρμογές Web

7 Αυγ 2012 (πριν από 5 χρόνια και 13 μέρες)

440 εμφανίσεις

PowerShell

Jeffrey P. Snover

Partner Architect

Agenda

Past

Present

Future


UNIX
Composable

Management

A | B | C

The heart of Unix
composable

management

Means that A didn’t do what you wanted to do

WHY?

A is a tight coupling of

Get Objects => Process Objects => Output as text

“| B | C” uses prayer
-
based parsing to recreate the object so you can do one
of the steps differently

.NET allows us to do better

Pipeline structured objects instead of text

Pipeline should be between get/process/Output


Successful but very inefficient

Composable Data Model Progression

UNIX:

Standardized data encoding (ASCII files) allows the emergence of
a set of domain
-
neutral utilities for composition and manipulation
(e.g.
sed
,
awk
,
grep
)

SQL:

Standardized data forms (Tables) allow the emergence of a set of
domain
-
neutral utilities for composition and manipulation (e.g. join,
query,
groupby
)

.NET Reflection:

Standardized object forms (
.net

objects) allow the emergence of a
set of domain
-
neutral
utilities
for composition and manipulation

PowerShell Dynamic objects

.Net

Reflection model applied to XML, WMI, ADSI, ADO, etc

Extended types to ease composition, organize folklore, and
facilitate discovery


# of
commands

Delivered

Traditional

Model

Common
Engine, Language
& Utilities

Individual
Cmds

Common Functions

Economics for Developers

Dev
Costs

Test Costs

User Training

Present: Windows PowerShell

New 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

Demo: Short Introduction

Jeffrey P. Snover

Partner Architect

The Difference is OBJECTS!

Get
-
Process | Where { $_.handles

gt

500 } | Sort handles | Format
-
Table

Get
-
Process

Cmdlet

Common Windows PowerShell Parser

Windows PowerShell Pipeline Processor

Where
Cmdlet

Sort

Cmdlet

Format

Cmdlet

PowerShell
Engine

Exchange cmdlets

Configuration Data Access

AD

Registry

Meta

base

MAPI

Store

Process

boundary


Early
-
bound objs

WinForms

ADO.Net

PowerShell
Data Provider

WinForms

CLI

GUI

Setup

Scripts

Filters

Functions

Script Cmdlets [New in V2]

Ad Hoc

Run at the command line

Simple BASH style

Parameters are not named or typed

Formal

Parameters are named, typed, have
initializers

Sophisticated

Rich error handling

Support

Verbose,
-
Debug,
-
Confirm,
-
Whatif

Digitally signed

Styles of Scripting


Jeffrey Snover

Windows Management Partner Architect

Agenda

Past


Present

Future

State Of The Software

Phenomenal rate of adoption

Over 2 million downloads in
less than 18 months


Windows XP, Windows Vista,
Windows Server 2003

and 2008


Adopted by Exchange, SQL,
SCOM, SCVMM, and
SCDPM


CEC 2009 requirement


Dozens of 3
rd

party tools,
ISVs, and partners

Citrix,
VMWare
,
Websphere
, etc


Strong community
engagement, 27 PowerShell
MVPs


0
0.5
1
1.5
2
2.5
Millions

PowerShell Downloads

Tower Of Power

PowerShell books

Now available in

Japanese

German

French

More…

2007

2008

Exchange 2003 (VBScript)

E12 (Monad Script)

Mailbox
Statistics


Set
listExchange_Mailboxs

=
GetObject
("
winmgmts
:{
impersonationLevel
=impersonate}!
\
\
COMPUTERNAME
\
ROOT
\
MicrosoftExchangeV2").
InstancesOf
("
Exchange_Mailbox
")


For Each
objExchange_Mailbox

in
listExchange_Mailboxs

WScript.echo

"
AssocContentCount

=” +
objExchange_Mailbox.AssocContentCount

WScript.echo

"
DateDiscoveredAbsentInDS

=” +
objExchange_Mailbox.DateDiscoveredAbsentInDS

WScript.echo

"
DeletedMessageSizeExtended

=” +
objExchange_Mailbox
.
DeletedMessageSizeExtended

WScript.echo

"
LastLoggedOnUserAccount

=” +
objExchange_Mailbox
.
LastLoggedOnUserAccount

WScript.echo

"
LastLogoffTime

=” +
objExchange_Mailbox
.
LastLogoffTime

WScript.echo

"
LastLogonTime

=” +
objExchange_Mailbox
.
LastLogonTime


WScript.echo

"
LegacyDN

=” +
objExchange_Mailbox
.
LegacyDN

WScript.echo

"
MailboxDisplayName

=” +
objExchange_Mailbox
.
MailboxDisplayName

WScript.echo

"
MailboxGUID

=” +
objExchange_Mailbox
.
MailboxGUID


WScript.echo

"
ServerName

=” +
objExchange_Mailbox
.
ServerName


WScript.echo

" Size =” +
objExchange_Mailbox
. Size

WScript.echo

"
StorageGroupName

=” +
objExchange_Mailbox
.
StorageGroupName


WScript.echo

"
StorageLimitInfo

=” +
objExchange_Mailbox
.
StorageLimitInfo


WScript.echo

"
StoreName

=” +
objExchange_Mailbox
.
StoreName


WScript.echo

"
TotalItems

=” +
objExchange_Mailbox
.
TotalItems



Next

get
-
mailboxstatistics




server $
servername

Database
Mgmt


Dim StorGroup as New CDOEXM.StorageGroup


StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First Storage
Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group,
CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services,
CN=Configuration," + DomainName


StorGroup.MoveLogFiles("C:
\
newlogPath", 0)

move
-
storagegrouppath



-
identity “First Storage


Group“



log "C:
\
newlogPath”

Recipient
Mgmt

Dim objMailbox As CDOEXM.IMailboxStore


Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName)


objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage
Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group,
CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services,
CN=Configuration," + DomainName

enable
-
mailbox


-
identity domain
\
FOO



database “First Storage


Group
\
Private MDB”

Agenda

Past


Present

Future

PowerShell Architecture

User
Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Mgr

Managed
Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

PowerShell V2 Themes

GUI over PowerShell

Production

Scripting

Universal Code Execution Model

Community Feedback

PowerShell V2 Themes

Admin GUIs layer on top of PowerShell

CLI
&

GUI

Agility in delivering new GUIs

Ensures automation

GUI teaches command line

Standardizes access to managed elements

GUI over PowerShell

User
Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Mgr

Managed
Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

GUI Over PS: Features

Graphical
PowerShell

Out
-
Gridview

New APIs

Runspace

Pooling

Thread Control

22

GUI Over PowerShell

PowerShell V2 Themes

Scripts are

Easy to use

Safe
to operate

Easy to share

Easy to support


Production

Scripting

User
Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Mgr

Managed
Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Production Scripting: Features

Script Cmdlets

Data Language

Modules

Debugger Enhancements

Transactions

Script Cmdlets

Native Code

25

Production Scripting

Jeffrey
Snover

Partner Architect

MSD Solutions and Platforms

PowerShell V2 Themes

Expressions, Commands, and ScriptBlocks can
run

In the foreground or background

On one or more machines

Over a LAN or a WAN

In restricted or unrestricted environments

Using short or long connections

Using impersonation or supplied credentials

Initiated by user input or by events


Universal Code Execution Model

User
Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Mgr

Managed
Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

UCCE Features

Remoting

Background Jobs

Eventing

Restricted
Runspaces

Mobile Object
Model

Mobile Objects Model

Islands of optimization in a sea of
interoperability

Whenever possible, use live .NET objects

Use typed property bags everywhere else

Live objects get serialized at runspace borders

Typed property bags using 22+ core datatypes

Everything else is converted using ToString()

Process can be tweaked with
typeXML

entries

Automatically
deserialized

into typed property
bags on receipt

Type:
Deserialized.OriginalType

PSComputerName




29

Universal Code
Execution

Jeffrey Snover

Partner Architect

MSD Solutions and Platforms

PowerShell V2 Themes


Respond to community feedback

Enhance the language

Tweak the engine

Add and enhance Cmdlets

Community Feedback

User
Experience

Shell

Language

Debugger

Engine

APIs

Execution Context

Object Mgr

Managed
Elements

Cmdlets

WMI

COM

.NET

XML

ADO

ADSI

Native Commands

Community Feedback: Features

Language
Enhancements

Improved

Object


Adapters

New Cmdlets

WMI++

New Cmdlets (So Far)

Remoting
:

Invoke
-
Command

New
-
Runspace

Get
-
Runspace

Push
-
Runspace

Pop
-
Runspace

Remove
-
Runspace

Converting Types:

Add
-
Type

ConvertTo
-
Csv

ConvertFrom
-
Csv

ConvertTo
-
Xml

ConvertFrom
-
StringData

Event Viewer and ETW
Logs:

Get
-
Event


Script Internationalization:

Import
-
LocalizedData

Modules:

Add
-
Module

Get
-
Module

Remove
-
Module

Export
-
ModuleMember

Debugging:

Set
-
PSBreakpoint

Get
-
PSBreakpoint

Enable
-
PSBreakpoint

Disable
-
PSBreakpoint

Remove
-
PSBreakpoint

Get
-
PSCallStack


Eventing
:

Register
-
ObjectEvent

Register
-
PSEvent

Wait
-
PSEvent


Remove
-
PSEvent

Unregister
-
PSEvent


Get
-
PSEvent

New
-
PSEvent

Get
-
PSEventSubscriber


Background Jobs:

Start
-
PSJob

Get
-
PsJob

Stop
-
PSJob

Receive
-
PSJob

Wait
-
PSJob


Remove
-
PSJob

Transactions:

Complete
-
PSTransaction

Start
-
PSTransaction

Undo
-
PSTransaction

Use
-
PSTransaction

WMI:

Register
-
WMIEvent


Set
-
WMIInstance

Invoke
-
WMIMethod

Remove
-
WMIObject

More Cmdlets:

Clear
-
History

Get
-
Random

Out
-
GridView

Set
-
StrictMode

Update
-
List

Wait
-
Process

WMI+++

Cmdlets

Get
-
WmiObject
, Remove
-
WmiObject

Set
-
WMIInstance

Invoke
-
WmiMethod

Register
-
WMIEvent

New parameters

-
Impersonation,
-
Authentication,
-
Locale,

-
EnableAllPrivileges
,
-
Amended,
-
DirectRead
,

-
Authority

-
AsJob

and
-
ThrottleLimit

(!)

Connection settings stay with the object [bug fix]



Newsgroup:
Microsoft.Public.Windows.PowerShell

Team blog:

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

PowerShellCommunity.Org
:

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

Many excellent books

Manning Press book by PowerShell Dev Lead Bruce Payette:
PowerShell in Action

http://manning.com/powershell/


O’Reilly book by PowerShell Dev Lee Holmes


Windows PowerShell Cookbook

http://www.oreilly.com/catalog/9780596528492/index.html


Questions?

http://blogs.msdn.com/powershell

©
2007
Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registere
d t
rademarks 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
dat
e 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 accu
rac
y 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.