search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 4,258 views | 10/02/2009 13:14

This is a basic deployment script for SCVMM to create VMs from templates. It was built in Turkish so I tried to translate it. You can adaptade this script to your own environment.

Popup menu codes are written by yefimovah. Link: www.powershellcommunity.org/Forums/tabid/54/aff/14/aft/487/afv/topic/Default.aspx

But all others codes are written by me. Please let me see your own script if you use and advanced this codes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Adding PS Snapin for SCVMM
 
Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
 
Get-Vmmserver localhost
 
# Pause Function
 
function Pause ($Message="Press any key to continue..")
{
Write-Host -NoNewLine $Message
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host ""
}
 
# Let's Create JobID
 
$JobGroupId = [Guid]::NewGuid().ToString()
 
# Sort VMs by Location
 
# get-vmhost hyperv01.fabrikam.contoso.net | Get-VM | Get-VirtualHardDisk | sort-object Location | Format-List Name,Location
 
# Pause
 
# get-vmhost hyperv02.fabrikam.contoso.net | Get-VM | Get-VirtualHardDisk | sort-object Location | Format-List Name,Location
 
# Pause
 
# Let's Create Pop-up Menu
 
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-null
 
# Variables
 
$form = new-object system.windows.forms.form

You can download all codes from here: http://www.yusufozturk.info/wp-content/uploads/2009/02/deployscriptps1.txt

Please leave a comment if you like or use it.


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 2,062 views | 16/01/2009 09:23

Merhaba,

VMM’de template olarak oluşturmuş olduğunuz sunucuları, otomatik olarak deploy edebilirsiniz. Bunun için yapmanız gereken aşağıdaki komutları, yazılımınıza uygun olarak adapte etmeniz ve gerekli kısımları değişkenlere bağlayarak son kullanıcının kullanımına hazır hale getirmeniz olacaktır. Aşağıda W2K3WEB isimli Windows 2003 Web template’inin VM0000 adıyla HYPERV7 isimli makinanın E:\DATA dizinine standart donanım ve “RHNetwork” isimli network ile deploy edilmesini sağlayan kodlar verilmiştir. Bu kodları komut satırından çalıştırmanız yeterli olacaktır.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ------------------------------------------------------------------------------
# New Virtual Machine Script
# ------------------------------------------------------------------------------
# Script generated on 16 Ocak 2009 Cuma 07:03:23 by Virtual Machine Manager
#
# For additional help on cmdlet usage, type get-help <cmdlet name>
# ------------------------------------------------------------------------------
 
Set-VirtualFloppyDrive -RunAsynchronously -VMMServer localhost -NoMedia -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc
 
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 1 -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc
 
Set-VirtualCOMPort -NoAttach -VMMServer localhost -GuestPort 2 -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc
 
New-VirtualNetworkAdapter -VMMServer localhost -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc -PhysicalAddressType Dynamic -VirtualNetwork "RHNetwork" -VLanEnabled $false
 
New-VirtualDVDDrive -VMMServer localhost -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc -Bus 1 -LUN 0
$CPUType = Get-CPUType -VMMServer localhost | where {$_.Name -eq "1.00 GHz Pentium III Xeon"}
 
New-HardwareProfile -VMMServer localhost -Owner "VMM\Administrator" -CPUType $CPUType -Name "Profiled92e430f-7870-46a6-a1b8-e2ff5d694f30" -Description "Profile used to create a VM/Template" -CPUCount 4 -MemoryMB 768 -ExpectedCPUUtilization 20 -DiskIO 0 -CPUMax 50 -CPUReserve 10 -NetworkUtilization 0 -RelativeWeight 100 -HighlyAvailable $false -NumLock $false -BootOrder "CD", "IdeHardDrive", "PxeBoot", "Floppy" -LimitCPUFunctionality $false -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc
 
$Template = Get-Template -VMMServer localhost | where {$_.Name -eq "W2K3WEB"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq "hyperv7.radore.net"}
$HardwareProfile = Get-HardwareProfile -VMMServer localhost | where {$_.Name -eq "Profileaf10fdd8-8e7c-41b4-bcf3-97442b64b5c2"}
New-VM -Template $Template -Name "VM0000" -Description "" -VMHost $VMHost -Path "E:\DATA" -JobGroup 37a760ce-8d30-464d-96f6-8e4da39846bc -RunAsynchronously -Owner "VMM\Administrator" -HardwareProfile $HardwareProfile -RunAsSystem -StartAction NeverAutoTurnOnVM -StopAction SaveVM

Bu kodlar, VMM’den alınmıştır. Farklı donanımlarda farklı kodlar da yaratabilirsiniz. Bunun için deploy adımlarından, son adıma ulaşarak “View Script” yazan butona basmanız yeterli olacaktır. Daha sonra bu kodları, bir panel aracılığı ile otomasyona bağlayabilirsiniz. Kolay gelsin.