SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


powerclirdmvms
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

powerclirdmvms [2013/04/20 13:39] (current)
sjoerd created
Line 1: Line 1:
 += Script: PowerCLI: VMs with RDM disks =
  
 +This is a remake of a script found on http://​www.virtu-al.net/​2008/​12/​23/​list-vms-with-rdm/​ with the following changes:
 +* Added RDMs in virtualmode
 +* Added csv export
 +* Added the vmhost in the output
 +* Made some code readability changes
 +
 +<code powershell>​
 +#Script Source: http://​www.virtu-al.net/​2008/​12/​23/​list-vms-with-rdm/​
 +#​Connect-VIServer MYVISERVER
 +
 +$timestamp = Get-Date -format "​yyyyMMdd-HH.mm"​
 +# $csvFile = Read-Host "Enter csv file"
 +$csvfile = "​D:​\sjoerd\$timestamp-rdmvms.csv"​
 +
 +$report = @()
 +$vms = Get-VM | 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"​)){
 +         #​if($dev.Backing.CompatibilityMode -eq "​physicalMode"​){
 + $row = ""​ | select VMName, Host, HDDeviceName,​ HDFileName, Mode
 + $row.VMName = $vm.Name
 + $getvm = Get-VM $row.VMName
 + $row.Host = $getvm.VMHost
 + $row.HDDeviceName = $dev.Backing.DeviceName
 + $row.HDFileName = $dev.Backing.FileName
 + $row.Mode = $dev.Backing.CompatibilityMode
 + $report += $row
 + }   
 +   } 
 +   }
 +}
 +$report | export-csv -NoTypeInformation $csvfile
 +</​code>​
 +
 +{{tag>​scripts vmware}}
powerclirdmvms.txt ยท Last modified: 2013/04/20 13:39 by sjoerd