Hello, I have the script below which works fine but I would like to read the naa ID of the RDM rather than the vml ID. Also I'm trying to get the scsi adapter type for the RDMs (VMware PVSCSI, LSI Logic SAS...). This script uses Get-View and that is how I would like to keep it as we have quite an amount of VMs to scan through. I know I can achieve that through get-scsicontroller but again, I am trying without success to see how to get those properties through Get-View.
$report = @()
#$vCluster = Read-Host 'enter the vCluster name'
$vms = Get-Datacenter myDC | Get-VM | Get-View
foreach($vm in $vms)
{
foreach($dev in $vm.Config.Hardware.Device)
{
if(($dev.gettype()).Name -eq "VirtualDisk")
{
if($vm.config.Hardware.Device.sharedbus -eq "physicalSharing")
{
$row = "" | select VMName, HWLevel, ESXiHost, HDDeviceName, HDFileName
$row.VMName = $VM.Name
$row.HWLevel = $VM.config.Version
$row.ESXiHost = (get-vm $vm.Name).VMHost
$row.HDDeviceName = $dev.Backing.DeviceName
$row.HDFileName = $dev.Backing.FileName
$report += $row
}
}
}
}
Try like this.
There was a small error in your logic to detect the shared bus, that needs to be done on the controller, not the disk
#$vCluster = Read-Host 'enter the vCluster name'
$vms = Get-Datacenter myDC | Get-VM | Get-View
$report = foreach($vm in $vms){
foreach($dev in $vm.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualSCSIController]}){
if($dev.SharedBus -eq 'physicalSharing'){
$vm.Config.Hardware.Device | where{$dev.Device -contains $_.Key} |
Select @{N='VM';E={$vm.Name}},
@{N='HWLevel';E={$vm.config.Version}},
@{N='ESXiHost';E={(Get-VM $vm.Name).VMHost.Name}},
@{N='Controller';E={$dev.GetType().Name}},
@{N='HDDeviceName';E={$_.Backing.DeviceName}},
@{N='HDFileName';E={$_.Backing.FileName}}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this.
There was a small error in your logic to detect the shared bus, that needs to be done on the controller, not the disk
#$vCluster = Read-Host 'enter the vCluster name'
$vms = Get-Datacenter myDC | Get-VM | Get-View
$report = foreach($vm in $vms){
foreach($dev in $vm.Config.Hardware.Device | where{$_ -is [VMware.Vim.VirtualSCSIController]}){
if($dev.SharedBus -eq 'physicalSharing'){
$vm.Config.Hardware.Device | where{$dev.Device -contains $_.Key} |
Select @{N='VM';E={$vm.Name}},
@{N='HWLevel';E={$vm.config.Version}},
@{N='ESXiHost';E={(Get-VM $vm.Name).VMHost.Name}},
@{N='Controller';E={$dev.GetType().Name}},
@{N='HDDeviceName';E={$_.Backing.DeviceName}},
@{N='HDFileName';E={$_.Backing.FileName}}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
many thanks indeed Luc, that worked great! I'll do some text manipulation to carve out the naa ID out of the vml ID,
cheers!