SHIFT

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

User Tools

Site Tools


Sidebar

Sponsor:

Would you like to sponsor this site?
Or buy me a beer?:


Recently Changed Pages:

View All Pages
View All Q Pages


View All Tags


Sign up for Q to post comments.





WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Terms And Conditions for Q users


Pages with comments

PageDateDiscussionTags
2018/11/10 11:24 2 Comments
2017/04/20 16:35 1 Comment
2017/04/20 15:28 1 Comment
2017/04/20 15:23 1 Comment
2017/04/19 14:59 1 Comment
2017/04/19 14:45 3 Comments
2017/04/19 14:44 1 Comment
2017/04/17 20:10 1 Comment
2017/04/17 20:07 1 Comment
2017/04/17 19:58 1 Comment
2017/04/17 19:52 1 Comment

View All Comments

powerclirdmvms

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
#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
You could leave a comment if you were logged in.
powerclirdmvms.txt · Last modified: 2013/04/20 13:39 by sjoerd