Windows PowerShell and Windows Management Instrumentation

basiliskcanoeSoftware and s/w Development

Nov 2, 2013 (3 years and 7 months ago)

103 views

2

Windows
PowerShell

and Windows
Management Instrumentation:

Unveiling Microsoft’s best kept secret

Kirk Jackson

Senior Developer

Xero

http://pageofwords.com/

kirk@pageofwords.com

SVR316:

3

Introduction

Kirk Jackson

kirk@pageofwords.com

http://pageofwords.com

Senior Developer,
Xero

http://www.xero.com

Microsoft MVP

Wellington .NET Users Group

http://www.dot.net.nz


4

Objectives & Take
-
aways

What is WMI?

Using
PowerShell

over WMI

Script creation

PowerShell

over Hyper
-
V

Shipping now:
PowerShell

version 1

5

PowerShell

6

What is
PowerShell
?

New command line interface for Windows

Scripting environment for Windows

New programming language


Microsoft’s new platform for Server & Product
administrations

Designed for the Windows environment


7

Admin: Ye Old Way


COM
Component

Command
Line Tool

Admin Tool

Graphical User Interface

Windows or Server Product Functionality

WMI
Classes

8

Admin: The new way


Scripts

Windows
PowerShell

CmdLets

MMC Admin Tool

Graphical User Interface

Windows or Server Product Functionality

Microsoft .NET Framework

COM
Component

WMI
Classes

9

GUI over
PowerShell


10

Objects

“An object is a collection of parts
and how to use them”

Parts

Properties

Front Wheel

Back Wheel

Pedals

Saddle

Frame

Parts

How to use

Methods

Pedal

Steer Left

Steer Right

Apply Front Brake

Apply Rear Brake

How to use

11

Win32_Service object

Name

Parts

Properties

State

Description

StopService
()

How to use

Methods

StartService
()

PauseService
()

Windows

Service

12

Arrays

A collection of objects all in a row

Refer to them by number (starts at 0)

$list[0]


first item

$list[1]


second item

...

13

cmdlets

129 provided
cmdlets
, you can add more

> 360

cmdlets

in Exchange 2007
SnapIn

cmdlets

can be built using C#, VB.NET

Always named Verb
-
Noun

e.g. get
-
content, get
-
childitem
,

sort
-
object, select
-
object, where
-
object

cmdlets

declare their parameters, the runtime
parses them in a consistent way

cmdlets

can receive input from the pipeline


14

Top 4
cmdlets

1.
Get
-
Command

2.
Get
-
Member

3.
Get
-
Help and
-
?

4.
Get
-
PSDrive



15

Powerful books


Now available in

Japanese

German

French

More…

2007

2008

16

W
indows

M
gmt

I
nstrment
.

C
ommon

I
nformation

M
odel

What is WMI?


C
ourse,

I
t

M
atters!

W
hat

M
atters

I
t?

W

M

I


C

I

M

17

WMI Architecture


CIMV2

Namespace

Virtualization

Namespace

Class

Class

Class

Class

Class

Class

Class

Class

PowerShell

18

Get
-
WmiObject

Basic Parameters:

Namespace



Specifies the WMI repository where a
class is located

Class


Specifies the name of a WMI class to be
retrieved

List



Displays all classes in a given namespace

ComputerName



Specifies the computer to

connect to

Credential


Specifies credentials to use to connect
to host


19

PowerShell

Get
-
WmiObject

Administering servers in bulk

Which WMI class to use?

Administering Hyper
-
V

See my blog
http://pageofwords.com

for a
demo transcript

20

PowerShell

v2


GUI over PowerShell

Production

Scripting

Universal Code Execution Model

Community Feedback

21

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]



22

Take
-
aways

What is WMI?

Using
PowerShell

over WMI

Script creation

PowerShell

over Hyper
-
V

Related Content

Hands
-
on Labs


MGT51



Introduction to scripting with
PowerShell v1

MGT54



Advanced Windows PowerShell
Scripting

WIN 03



Buidling Windows PowerShell
Cmdlets

24

Resources

www.microsoft.com/teched


Tech∙Talks

Tech∙Ed

Bloggers

Live Simulcasts

Virtual Labs

http://microsoft.com/technet



Evaluation licenses, pre
-
released
products, and MORE!

http://microsoft.com/msdn



Developer’s Kit, Licenses,

and MORE!

25

Resources

My blog:

http://pageofwords.com

PowerShell

Team:
http://blogs.msdn.com/powershell

Ben Pearce:

http://blogs.technet.com/benp/

James O’Neill (Hyper
-
V
cmdlets
):

http://blogs.technet.com/jamesone/

PowerShell

Community Extensions

http://www.codeplex.com/PowerShellCX



26

Please
complete an

evaluation

27

©
2008 Microsoft
Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademar
ks
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 accuracy of any informatio
n p
rovided after the date of this presentation.
MICROSOFT
MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.