Below is script to find the RDM's in the VM in a given folder,
clear
Connect-VIServer -Server server
$report = @()
$folder = Get-Folder -Name name
$vms = Get-VM -Location $folder Get-View
foreach($vm in $vms){
foreach($dev in $vm.Config.Hardware.Device){
if(($dev.gettype()).Name -eq "VirtualDisk"){
if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or
($dev.Backing.CompatibilityMode -eq "virtualMode")){
$row = "" select VMName, HDDeviceName, HDFileName, HDMode
$row.VMName = $vm.Name
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$row.HDMode = $dev.Backing.CompatibilityMode
$report += $row
}
}
}
}
$report
Tuesday, December 16, 2008
Creating Multiple VM's from template
Below is a very basic power shell script my first script to create Multiple VM's from template
clear
Connect-VIServer -Server server-User "user" -Password "passwd"
Import-Csv -Path "file" %{New-VM -Template (Get-Template) -VMHost "esxhost" -Name $_.Name -Location (Get-Folder -Name) -Datastore "name_datastore"-network "name_network"
clear
Connect-VIServer -Server server-User "user" -Password "passwd"
Import-Csv -Path "file" %{New-VM -Template (Get-Template) -VMHost "esxhost" -Name $_.Name -Location (Get-Folder -Name) -Datastore "name_datastore"
Subscribe to:
Posts (Atom)