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 | 2,180 views | 17/02/2009 20:02

Kullanıcıyı owner olarak atamakta kullandığınız kullanıcı rolünü, aşağıdaki komut ile powershell üzerinden kaldırabilirsiniz.

1
2
3
$UserName = “JohnH”
$RemoveRole = Get-VMMUserRole | where {$_.Name -eq$UserName}
Remove-VMMUserrole -Userrole $RemoveRole

$RemoveRole’deki Get-VMMUserRole’ün önemli bir yeri var orada. Bu şekilde yapmazsanız, hata alacaksınız. Bilgilerinize..


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 3,452 views | 17/02/2009 19:59

You can remove/delete your user role with this command:

1
2
3
$UserName = "JohnH"
$RemoveRole = Get-VMMUserRole | where {$_.Name -eq "$UserName"}
Remove-VMMUserrole -Userrole $RemoveRole

You should use Get-VMMUserRole command to use Remove-VMMUserrole command.


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 2,529 views | 16/02/2009 02:29

Powershell üzerinden VM oluştururken, işletim sistemi şifresi belirtmek istediğinizde, password ile ilgili hata alabilirsiniz. Bu sorunu çözmek için clear haldeki şifrenizi önce SecureString haline getirip, sonra System.Management.Automation.PSCredential haline getirmeniz gerekiyor.

1
2
3
$SecurePassword = ConvertTo-SecureString "SIFREM" -AsPlainText -Force
$Credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist Administrator, $SecurePassword
New-VM -AdminPasswordCredential $Credentials

New-VM komutu içersine -AdminPasswordCredential argümanını ekleyerek, işletim sistemi şifresini belirleyebilirsiniz. Kolay gelsin.


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 4,290 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, Windows Server | No Comment | 2,850 views | 29/01/2009 23:53

Powershell üzerinde SCVMM (System Center Virtual Machine Manager) ile ilgili bir komut çalıştırmak istediğinizde, muhtemelen aşağıdaki hatayı alıyorsunuz:

The term ‘X’ is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.

Bu da Powershell üzerinde VMM Snapin eklemeden işlem yapamadığınız anlamına geliyor. Şimdi Powershell’e SCVMM kütüphanesini attach edelim.

1
Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager

For English Users: You need to attach SCVMM library to Powershell if you want to use VMM commands in Powershell. To do that, you can use the code above.


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 2,168 views | 26/01/2009 21:31

VMM üzerinden yönettiğiniz Hyper-v sunucunuzda yeterli ram kalmadıysa ve ram upgrade yapamayacaksanız, ikinci bir hyper-v sunucusu eklemeyi düşünmeniz gerekiyor. Bu ekleme işlemini başlatmadan önce, yeni hyper-v sunucusunu kurup, Active directory’e üye yapmalısınız. Daha sonra Hosts tabı içersinde, Virtual Machine Manager menüsünden, “Add host” bağlantısını seçiyoruz. Sonrasında aşağıda görebileceğiniz gibi “Windows Server-based host on an Active Directory Domain” seçerek, sunucuya kurulum yapabilmek için yetkili kullanıcı bilgilerini giriyoruz.

Sonraki adım zaten sunucuyu seçmeniz gereken bölüm olacaktır. Farkedeceğiniz gibi Hyper-v yüklü sunucuların ikonları daha farklı gözükmekte. Sunucuyu seçtikten sonra işlem tamamlanacak ve yeni sunucunuz vmm’e eklenmiş olacaktır. Powershell üzerinden de bu işlemi gerçekleştirebilirsiniz.

1
2
3
$Credential = get-credential
$VMHostGroup = Get-VMHostGroup -VMMServer localhost | where {$_.Path -eq "All Hosts"}
Add-VMHost -VMMServer localhost -ComputerName "hyperv08.hyperv.pluvia.org" -Description "" -Credential $Credential -RemoteConnectEnabled $true -VmPaths "" -Reassociate $false -RunAsynchronously -RemoteConnectPort 2179 -VMHostGroup $VMHostGroup

Örnekteki işlemde, hyperv08.hyperv.pluvia.org isimli sunucu, VMM üzerinde “All Hosts” altına eklenecektir. Remote Connection Port’u 2179 olarak ayarlanmıştır. Yapınızda Firewall varsa, bu porta yönelik kural girmeniz gerekiyor. Powershell komutlarının nasıl kullanılabildiğini daha önceki yazılarımda yazmıştım. Kolay gelsin.


Posted in Virtual Machine Manager, Windows Powershell | No Comment | 2,039 views | 19/01/2009 08:30

VMM üzerindeki bir sanal sunucuyu, aynı hyperv’nin farklı bir hdd’sine ya da tamamen farklı bir hyperv’ye taşıyabilmekteyiz. Farklı bir Hyperv’ye taşıması işlemi sırasında sunucuyu “save state” ile dondurmakta, taşıma işlemi bittikten sonra geri açmaktadır. HDD’ler arasındaki taşıma işlemi de bazı nedenlerden dolayı işimize yaramaktadır. Örneğin VM klasör isimleri değiştirilememektedir. Yani ilk kurulum sırasında klasör ismi olarak ne verdiyseniz, o şekilde kullanmaya devam edersiniz. Fakat migrate işlemi ile bu sorunu da aşabilirsiniz. Farklı bir HDD’ye taşırken, VM’e farklı bir isim verebilir ve bu klasör isminin değişmesini sağlayabilirsiniz. Şimdi migrate için Powershell üzerindeki taşıma scriptine göz atalım.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# ------------------------------------------------------------------------------
# Migrate Virtual Machine Wizard Script
# ------------------------------------------------------------------------------
# Script generated on 18 Ocak 2009 Pazar 20:23:34 by Virtual Machine Manager
#
# For additional help on cmdlet usage, type get-help <cmdlet name>
# ------------------------------------------------------------------------------
 
$VirtualNetworkAdapter = Get-VirtualNetworkAdapter -VMMServer localhost -All | where {$_.ID -eq "042af40a-afa9-4c07-8458-be08efa24eae"}
 
Set-VirtualNetworkAdapter -VirtualNetworkAdapter $VirtualNetworkAdapter -RunAsynchronously -VirtualNetwork "RHNetwork" -NetworkTag "" -NetworkLocation "" -JobGroup fdef0e55-5bac-4033-969a-adb8a8277f8a -VLanEnabled $false
 
$VM = Get-VM -VMMServer localhost -Name "VM0000" | where {$_.VMHost.Name -eq "hyperv9.radore.net"}
$VMHost = Get-VMHost -VMMServer localhost | where {$_.Name -eq "hyperv4.radore.net"}
 
Move-VM -VM $VM -VMHost $VMHost -Path "C:\Hyper-V" -RunAsynchronously -UseLAN -JobGroup fdef0e55-5bac-4033-969a-adb8a8277f8a

Yukardaki script’te, VM0000 isimli makina, hyperv4 isimli sunucudan, hyper9 isimli sunucunun C:\Hyper-V dizinine, RHNetwork ağına sahip olacak şekilde taşınmaktadır. Yani bu script ile ilgili değişkenlerin değişmesini sağlayacak bir panel yardımı ile VMM’e gerek kalmadan taşıma işlemi yaptırabiliriz. Kolay gelsin.