PowerClI locate all the SCSI Bus Sharing VM’s

More things that stop vMotion like SCSI Bus Sharing here is a snippet to locate all of them in a cluster

#Create the array

$array = @()

$vms = get-cluster “ClusterName” | get-vm

#Loop for BusSharingMode

foreach ($vm in $vms)

{

 

$disks = $vm | Get-ScsiController | Where-Object {$_.BusSharingMode -eq ‘Physical’ -or $_.BusSharingMode -eq ‘Virtual’}

 

foreach ($disk in $disks){

$REPORT = New-Object -TypeName PSObject

$REPORT | Add-Member -type NoteProperty -name Name -Value $vm.Name

$REPORT | Add-Member -type NoteProperty -name VMHost -Value $vm.Host

$REPORT | Add-Member -type NoteProperty -name Mode -Value $disk.BusSharingMode

$REPORT | Add-Member -type NoteProperty -name Type -Value “BusSharing”

$array += $REPORT

}

 

 

}

$array | out-gridview

4 Replies to “PowerClI locate all the SCSI Bus Sharing VM’s”

  1. found it very useful, can you please add some more details to the output file like, LUN ID, naa id, vml file, size
    whatever possible from those fields.

    Really appreciate it.

    1. Thanks for reading. I personally don’t have access to an environment with RDM’s to test but here is the basics:

      $disks = $vm | Get-ScsiController | Where-Object {$_.BusSharingMode -eq ‘Physical’ -or $_.BusSharingMode -eq ‘Virtual’}

      $disks is an array of data on SCSI controller data so a few elements will not be present without coordinating the VM with luns for example LUN ID is a element of the LUN not the controller. You can see all elements available in the controller via

      $disks | fl

      Any of those elements can be added. I know it’s not the full answer but without an environment to test on it would be guess work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.