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,628 views | 03/11/2009 13:42

You don’t need any storage server to use Hyper-V. We have Dell Blade servers and also Core i7 OEM servers. So if you have OEM servers, you have to choose VM locations carefully. Because your SATA disks will effect your virtual machines performance directly. So you have to check all SATA disks and find the best disk for the best performance. For that reason, i made this script. With VMDetails.ps1, you will always find the best SATA disk to deploy your Virtual Machine.

Also with VMDetails.PS1, you don’t need to know “Virtual Network Name” of your Hyper-V Host. If you just type “Auto”, it looks for Virtual Networks and choose the best Virtual Network Name. Also you can exclude any Virtual Network like “Backup Network”.

How about Best Hyper-V Host? Just type “Auto” for Hyper-V host name and you will get the Best Hyper-V host to deploy your virtual machines. This script looks all your hyper-v hosts and choose the best one for the best performance.

VMDetails.ps1 Preview:

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
##########################
####   VMDETAILS.PS1  ####
##########################
 
# Gets Template and Hardware Details
 
function Get-VMDetails
{
param ($VMHost, $Template, $HardwareProfile, $HDDPart, $Network, $ExcludedHDD, $ExcludedNetwork)
 
    $Temp = Get-Template | Where { $_.Name -eq "$Template" }
    $OperatingSystem = $Temp.OperatingSystem.Name
    $SysprepScript = $Temp.SysprepScript.SharePath
 
    $Hardware = Get-HardwareProfile | Where { $_.Name -eq "$HardwareProfile" }
    $CpuType = $Hardware.CPUType.Name
 
    If ($VMHost -eq "Auto")
    {
        $BestServer = Get-VMHost * | Select-Object -Property Name,AvailableMemory | Sort-object AvailableMemory | Select-Object -Last 1
        $VMHostName = $BestServer.Name
        $HDDPart = $HDDPart
 
        If ($HDDPart -eq "Auto:")
        {
            $BestDisk = (Get-VMHost $VMHostName).DiskVolumes
 
            Foreach ($i in $BestDisk)
            {
                If ($i -like "$ExcludedHDD*")

You can download from here: VMDetails.ps1

Usage:

Get-VMDetails -VMHost $VMHost -Template $Template -HardwareProfile $HardwareProfile -HDDPart $HDDPart -Network $Network -ExcludedHDD $ExcludedHDD -ExcludedNetwork $ExcludedNetwork

Params:

$Template: Virtual Machine Template for Deploy
$HardwareProfile: Hardware Profile for Template
$VMHost: One of your Hyper-V Servers’ Name in VMHosts (like hyperv02 or Auto)
$HDDPart: Hard Disk Partition (like C:, D:, E: or Auto)

Example:

Get-VMDetails -VMHost hyperv02 -Template W2K8R2STDT1 -HardwareProfile TEMP2GB -HDDPart Auto -Network Auto -ExcludedHDD "C:" -ExcludedNetwork "Backup Network"

How can you use results?

1
2
3
4
5
6
7
8
$VMDetails = Get-VMDetails -VMHost "$VMHost" -Template "$VMTemplate" -HardwareProfile "$HardwareProfile" -HDDPart "$HDDPart" -Network "$NetworkName" -ExcludedHDD "$ExcludedHDDPart" -ExcludedNetwork "$ExcludedNetwork"
 
$CpuType = $VMDetails.CpuType
$OperatingSystem = $VMDetails.OperatingSystem
$SysprepScript = $VMDetails.SysprepScript
$VMHostName = $VMDetails.VMHostName
$HDDPart = $VMDetails.HDDPart
$NetworkName = $VMDetails.NetworkName

Also I updated the script. Now If you use Windows Server 2008 R2, the “Reserved System Partition” is auto excluded.

Have Fun!