Archive

Archive for June, 2009

Report on HA Isolation Response

June 17th, 2009 Eric No comments
$desiredResponse = "DoNothing"
 
foreach ($cluster in Get-Cluster)
{
    $result = $cluster | Select-Object Name, HAIsolationResponse,
                             @{Name="DesiredResponse"; Expression={$desiredResponse}}
 
    if (!$cluster.HAEnabled)
    {
        $result.HAIsolationResponse = "HaNotConfigured"
    }
 
    $result
}
Categories: Scripting, VMware Tags:

LoadVMs-FromFile

June 1st, 2009 Eric No comments

I was using the VMware VI Toolkit for Windows for a change and I needed to load VMs from a CSV and my typical stream oriented way of doing this was very inefficient over the WAN (or LAN really). There are many ways of making Get-VM operations faster, but for this change I decided to use the standard Get-VM cmdlet with an array of computer names instead of doing them one by one.

Below is the function I wrote to make this easier for repeated use. The csv should have the computer name under a ‘Name’ column heading. All other columns are ignored.

Example file
Field1,Name,Field3,FieldN
“”,”testvm01″,”",”"
“”,”testvm02″,”",”"

1
2
3
4
5
6
7
8
9
10
function LoadVMs-FromFile
{
    param
    (
    $file = $(throw "A file must be specified.")
    )
    $vmNames = @()
    Import-Csv $file | % {$vmNames += $_.Name}
    Get-VM $vmNames
}
Categories: Scripting, VMware Tags:

Switch to our mobile site