您的位置:首页 > 运维架构 > Shell

通过SCVMM的Poweshell管理VM(1)----在Hyper-Server上创建虚拟机

2010-08-25 18:35 309 查看

Initialize

1. Start Powershell via command line

C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -PSConsoleFile "C:/Program Files/Microsoft System Center Virtual Machine Manager 2008 R2/bin/cli.psc1" -NoExit

Restore

1. Connect to the Virtual Machine Manager (VMM) server, server name: sst-scvmm-server

$VMMServer = Get-VMMServer -ComputerName " sst-scvmm-server "

2. Get image object "vm" from Image Library Server:sst-image-2.adobenet.global.adobe.com

$VMName=get-vm|where {$_.LibraryServer.Name -eq "sst-image-2.adobenet.global.adobe.com"}

3. Get and sort the host ratings for all the hosts in the host group , return sorted host array

$HostRatings = Get-VMHostRating -VM $VMName | where { $_.Rating -gt 0 } | Sort-Object -property Rating -descending

If($HostRatings.Count -eq "0") { throw "No hosts meet the requirements." }

4. Set new vm's hardware as request

New-HardwareProfile -Name "LargeHAVM" -CPUCount 4 -MemoryMB 64000 -CPUMax 100 -Owner "User1@Contoso" –CPUType “Intel Core 2”
$HardwareProfile = Get-HardwareProfile | where {$_.Name -eq " LargeHAVM"}

5. Create new vm and deploy it on "vmhost", vmhost is the highest rate host

new-vm -vm $ VMName -Name "VM05" -Description "New VM from VM
stored" -owner "adobenet/bjsstqe" -vmhost $vmhost -path "c:/programdata/microsof
t/windows/hyper-v" -HardwareProfile $HardwareProfile

6. Set new vm's MAC address as assigned

$vm=get-vm|where {$_.name -eq " VM05"}
$vm_network=get-virtualnetworkadapter -vm $vm
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $vm_network -physicaladdress "00-00-00-00-00-00-00-E0"

7. Startup-VM

Start-vm –vm $vm

Checkpoint (Snapshot)

1. Create checkpoint for VM “VM01” and name it as “VM01-CP01”

Get-VM -name "VM01" | New-VMCheckpoint -name " VM01-CP01" (Need to try)

2. Create a new VM based on “VM01” and store the VM to Image Library Server “Image-Lib.pac.adobe.com”

Get-VM -VMMServer localhost -Name " VM01" | where {$_.VMHost.Name -eq "sst-hyperv-2.adobenet.global.adobe.com"}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: