Vous êtes sur la page 1sur 25

Hal Rottenberg hal@halr9000.

com

Hal

Rottenberg hal@halr9000.com

Over 12 years in the IT industry; everything

from helpdesk, to sysadmin, to technical


consultant
Author, Managing VMware Infrastructure with
PowerShell: TFM from Sapien Press (due out
as soon as he can possibly get it done)
Community Director, PowerShellCommunity.org
Co-Host, PowerScripting Podcast
(powerscripting.net)
Blog Author, TechProsaic (halr9000.com)

Introduction
Feature overview
Demo 1: new providers
New Cmdlets
Demo 2: wiki deploy
Demo 3: Creating a VM
Demo 4: Access VI SDK

Programming

API

Web service (WSDL)


Samples included for Java, C, C#
Low level

Scripting

API

Perl and COM interfaces available


Wrapper for web services

You still must learn


the VI SDK
Higher level than
SDK, but not by
much
Perl interface not
familiar to Windows
admins
COM interface was
not very popular,
hard to find
examples

PowerShell snap-in
Client-side automation objects
correspond to server-side managed
objects and managed entities
Not just a web service wrapper
Favors action-oriented cmdlets over object
methods
Goal: 80% of tasks will not require SDK
Ability to access the SDK for more
complex tasks

Fully

supported:

Virtual Center 2.x


ESX Server 3.x (including 3i)

Unofficially

supported:

VMware Server 2.0 beta

Works

with PowerShell v1 or v2 CTP

Includes
Count Name
----- ---1 Add
1 Connect
1 Disconnect
1 Dismount
37 Get
Datacenter,...
1 Mount
7 Move
Folde...
19 New
CustomField...
20 Remove
Cu...
2 Restart
27 Set
CustomField...
1 Shutdown
2 Start
3 Stop
2 Suspend
1 Test

over 120 cmdlets


Group
----{Add-VMHost}
{Connect-VIServer}
{Disconnect-VIServer}
{Dismount-Tools}
{Get-CDDrive, Get-Cluster, Get{Mount-Tools}
{Move-Cluster, Move-Datacenter, Move{New-CDDrive, New-Cluster, New{Remove-CDDrive, Remove-Cluster, Remove{Restart-VMGuest, Restart-VMHostService}
{Set-CDDrive, Set-Cluster, Set{Shutdown-VMGuest}
{Start-VM, Start-VMHostService}
{Stop-Task, Stop-VM, Stop-VMHostService}
{Suspend-VM, Suspend-VMGuest}
{Test-VMHostSNMP}

Also includes two PSProviders


Remote filesystem (datastore) access via

VimDatastore provider
Hierarchical management of Folders, Datacenters,
VMHosts, VMs using VimInventory provider

Name
---VimDatastore
VimInventory

Capabilities
-----------Filter, ShouldProcess
Filter

Drives
-----{DS}
{VI}

VimInventory
VimDatastore
New-PSDrive
-Root '/'
New-PSDrive
-Root '/'

EXPERIMENTA
L!

-Name VI -PSProvider VimInventory `


-location (Get-Folder -NoRecursion)
-Name DS -PSProvider VimDatastore `
-location (Get-Datastore $DatastoreName)

Get-VM
Get-VMHost

PS > Get-VM
Name
PS
> Get-VMHost
---SDK-RHAS4U4
Name
SDK-W2003ENT
---fudgeapp01
192.168.0.51
fudgedb01
192.168.0.55
vcenter.halr9000.com
fudgedb02
SDK-XPSP2

Get-CDDrive
Get-Cluster

PowerState Num CPUs


---------- -------PoweredOffState
1
PoweredOff----1
PoweredOffConnected
1
PoweredOffConnected
1
PoweredOn 2
PoweredOff 1
PoweredOff 1

Memory (MB)
----------512
Id
256
-256
HostSys...
512
HostSys...
1500
1024
256

PS > Get-VM vcenter.halr9000.com | Get-CDDrive


ISOPath
HostDevice
RemoteDevice
ConnectionState
ID
Name

:
:
:
:
:
:

PS > Get-Cluster "test cluster" | fl

HAEnabled
: False
VMware.VimAutomation.Client20.ConnectInfoImpl
HAAdmissionControlEnabled : False
VirtualMachine-vm-158/3000
HAFailoverLevel
: 1
CD/DVD Drive 1
DRSEnabled
: False
DRSMode
: FullyAutomated
CustomFields
: {}
ID
: ClusterComputeResource-domain-c44
Name
: Test Cluster

New-Datacenter
New-Cluster
Add-VMHost
New-VM

Create

folders wiki-style

Cmdlets
New-VM

used:

Remove-Snapshot
Move-VM
Set-NetworkAdapter
Restart-VMGuest

Cmdlets

used:

New-Snapshot

get-vm

MYSERVER | move-vm -dest


(get-vmhost ESX2)
get-cluster TEST | get-vm | move-vm
dest (get-cluster PRODUCTION)

Get-VIEvent
Get-Task
Get-Log
Get-Stat

Cmdlets

used:

Get-VIEvent

When

the simplified interface


doesnt cut ityou can always work
with the SDK
Cmdlets used
Get-View

ISCSI

Configuration

VI Toolkit: http://vmware.com/go/powershell
VI Toolkit blog:
http://blogs.vmware.com/vipowershell/
VI Toolkit Community:
http://communities.vmware.com/community/d
eveloper/windows_toolkit
PowerShellCommunity.org:
http://powershellcommunity.org
PowerScripting Podcast:
http://powerscripting.net
Managing VI with PowerShell: TFM:
http://sapienpress.com/vmware.asp
Hals Blog: http://halr9000.com

Vous aimerez peut-être aussi