Download - Chinmay Gokhale SE | Microsoft [email protected].

Transcript
Page 1: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

PowerShell scripting for virtualized environment

Chinmay GokhaleSE | [email protected]

Page 2: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

Virtualized Workload Management

System Center SuiteSCVMM - Virtualization Platform Management SCCM - Offline patching of virtual machines.SCOM- PRO Tips and Health Monitoring.SCDPM - Provides data protection on mission critical systems

Page 3: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

SCVMM Console Managing :Hyper-V Virtual Server 2005 R2 SP1

DEMO

Page 4: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

Why Windows Powershell?

It’s a full-fledged scripting language which can access command-line utilities and the Windows Management Interface (WMI). Powerful and Object Oriented shellSchedule complex tasks to run as script

Page 5: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

PowerShell and SCVMM Command-line shell and scripting language

170 command-line functions 13 classes from Hyper-VFoundation for VMM administrator’s console and Self Service PortalAll PowerShell operations are logged and audited

Consistent scripting syntax and utilities that integrate with established tools and proceduresAll functions of the Hyper-V MMC and VMM Admin Console can be done via PowerShell

Page 6: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

DEMO# ------------------------------------------------------------------------------------------# New Virtual Machine Script to create and store New VM in Library# ------------------------------------------------------------------------------------------# Script generated on <date/time stamp> by Virtual Machine Manager# # For additional help on cmdlet usage, type get-help <cmdlet name># ------------------------------------------------------------------------------------------New-VirtualNetworkAdapter –VMMServer localhost –JobGroup 18f4314f-97bc-4230-9896-65c935856379

PhysicalAddressType Dynamic –VLanEnabled $false

New-VirtualDVDDrive –VMMServer localhost –JobGroup 18f4314f-97bc-4230-9896-65c935856379 –Bus 1 –LUN 0

$CPUType = Get-CPUType –VMMServer <VMM HOST DETAILS> | where {$_.Name –eq “1.20 GHz Athlon MP”}

New-HardwareProfile –VMMServer localhost –Owner “<Owner Details>” –CPUType $CPUType –Name “Profile6fdcd372-f17a-401a-b9dc-ea88d59daceb” –Description “Profile used to create a VM/Template” -CPUC

Page 7: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

Managing Hyper-V with PowerShell

Use WMI; Hyper-V WMI namespace is located asroot\virtualization

Msvm_VirtualSystemManagementService

Create and delete virtual machines, Import, export, and snapshot virtual machines

Msvm_VirtualSwitchManagementService

Create and delete networking resourcesMsvm_ImageManagementService

Create, mount, and dismount virtual media (vhd and vfd)

Page 8: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

13 Hyper-V Virtualization WMI Classes

BIOS Classes Integration Component Classes

Input Classes Resource Management Classes

Memory Classes Virtual System Management

Networking Classes Serial Devices Classes Processor Classes Virtual System Classes Profile RegistrationVideo Classes Storage Classes

Page 9: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

WMI Management Services

Page 10: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

Get-WmiObject -namespace root\virtualization-class Msvm_ComputerSystem-computername localhost

Get-WmiObject -namespace root\virtualization-class Msvm_ComputerSystem | Get-Member

Get-WmiObject -namespace root\virtualization-class Msvm_ComputerSystem| Format-Table ElementName, EnabledState

DEMO

Page 11: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

• PowerShell Scriptomatichttp://www.microsoft.com/technet/scriptcenter/tools/psomatic.mspx

• WMI Code Creatorhttp://www.microsoft.com/technet/scriptcenter/createit.mspx

• PowerShell Editor (and it’s FREE!)http://powergui.org/index.jspa

Scripting More Easy

Page 12: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

References

Microsoft System Center Virtual Machine Manager Homepage: http://www.microsoft.com/scvmm Tech Center (for documentation and downloads):

http://technet.microsoft.com/scvmm/default.aspx Microsoft Virtualization Homepage

http://www.microsoft.com/virtualization Microsoft System Center Homepage

http://www.microsoft.com/systemcenter/ Microsoft Windows Server 2008 Hyper-V Homepage

http://www.microsoft.com/hyper-v/

Page 13: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

PowerShell Hyper-V Resources

Hyper-V WMI documentationhttp://msdn2.microsoft.com/enus/library/cc136992(VS.85).aspx

Virtual PC guyhttp://blogs.msdn.com/Virtual_PC_Guy/

Powershell management library for Hyper-Vhttp://www.codeplex.com/PSHyperv

Page 14: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

Feedback / QnA

Your Feedback is Important!Please take a few moments to fill out our

online feedback form at:

For detailed feedback, use the form at http://www.connectwithlife.co.in/vtd/helpdesk.aspx

Or email us at [email protected]

Use the Question Manager on LiveMeeting to ask your questions now!

Page 15: Chinmay Gokhale SE | Microsoft Chinmay.Gokhale@microsoft.com.

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