blog.powershell.no

On Windows PowerShell and other admin-related topics

System Center Virtual Machine Manager 2008 and PowerShell

I`ve been playing around with System Center VMM 2008 lately, and I really like “View Script”-button:

new_vm_demo

Clicking on the button you get a text-file containing the script which is being run when you press “Finish”. (Almost the same functionality in Exchange 2007, the difference is that you must press Ctrl + C rather than a button to copy the script/command being run in the Exchange Management Console).

Sample textfile-output:

# ------------------------------------------------------------------------------ # New Virtual Machine Script # ------------------------------------------------------------------------------ # Script generated on 18. desember 2008 18:46:03 by Virtual Machine Manager # # For additional help on cmdlet usage, type get-help <cmdlet name> # ------------------------------------------------------------------------------ New-VirtualNetworkAdapter -VMMServer localhost -JobGroup 6928344f-7732-4e1b-b852-15cf0288cd2f -PhysicalAddressType Dynamic -VLanEnabled $false New-VirtualDVDDrive -VMMServer localhost -JobGroup 6928344f-7732-4e1b-b852-15cf0288cd2f -Bus 1 -LUN 0 $CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq "1.20 GHz Athlon MP"} New-HardwareProfile -VMMServer localhost -Owner "RBK\jer" -CPUType $CPUType -Name "Profiledb3743da-b115-4c6b-bab5-6cbf89fde1ad" -Description "Profile used to create a VM/Template" -CPUCount 1 -MemoryMB 512 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder "CD", "IdeHardDrive", "PxeBoot", "Floppy" -LimitCPUFunctionality $false -JobGroup 6928344f-7732-4e1b-b852-15cf0288cd2f New-VirtualDiskDrive -VMMServer localhost -IDE -Bus 0 -LUN 0 -JobGroup 6928344f-7732-4e1b-b852-15cf0288cd2f -Size 40960 -Dynamic -Filename "Demo-01_disk_1" $VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq "HYPER-V-JR.rbk.ad"} $HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq "Profiledb3743da-b115-4c6b-bab5-6cbf89fde1ad"} $OperatingSystem = Get-OperatingSystem -VMMServer localhost | where {$_.Name -eq "Windows Server 2008 Standard 32-Bit"} New-VM -VMMServer localhost -Name "Demo-01" -Description "" -Owner "RBK\jer" -VMHost $VMHost -Path "D:\Hyper-V" -HardwareProfile $HardwareProfile -JobGroup 6928344f-7732-4e1b-b852-15cf0288cd2f -RunAsynchronously -OperatingSystem $OperatingSystem -RunAsSystem -StartAction NeverAutoTurnOnVM -StopAction SaveVM

Now you can save it as a ps1-file and tweak as wanted. This makes it really easy to get started automating tasks in SCVMM.

Btw, SC VMM 2008 is a really great product, making it possible to manage Virtual Server 2005, Hyper-V and VMWare ESX 🙂

Advertisements

December 18, 2008 - Posted by | Scripting, Virtualization

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: