I have been banging my head trying to get the IOPS field added to our RDM report.
I'm wanting the column to show the -CommandsToSwitchPath but the column is empty everytime I try.
Here is what I have and I'll take any suggestions at this point!
Get-VM | Sort-Object | Get-HardDisk | Where-Object {$_.DiskType -like “Raw*”} |
Select @{N=”VMName”;E={$_.Parent}},Name,DiskType,@{N=”LUN_ID”;E={$_.ScsiCanonicalName}},
@{N='SCSIid';E={$th = $_
$ctrl = $th.Parent.Extensiondata.Config.Hardware.Device | Where {$_.Key -eq $th.ExtensionData.ControllerKey}
"$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"}},Filename,CapacityGB,@{N="IOPS";E={Get-ScsiLun -LunType disk | Select-Object CommandsToSwitchPath}} |
Export-Csv "C:\RDM_IOPS.csv" -NoTypeInformation
The problem is this part and I don't think I'm doing this right:::
@{N="IOPS";E={Get-ScsiLun -LunType disk | Select-Object CommandsToSwitchPath}}
That seems to indicate you have shared RDM, connected to multiple VMs.
Try this variation, it will show all VMs connected to a shared RDM LUN
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns = @()
# Get all RDM luns and store with VM name
$lunTab = @{}
Get-VM -Location $getCluster -PipelineVariable vm |
Get-HardDisk | Where-Object { $_.DiskType -like “Raw*” } |
ForEach-Object -Process {
if($lunTab.ContainsKey($_.ScsiCanonicalName)) {
$lunTab[$_.ScsiCanonicalName] = $lunTab[$_.ScsiCanonicalName], $vm.Name -join '|'
}
else {
$lunTab.Add($_.ScsiCanonicalName,$vm.Name)
}
}
foreach ($getESXi in $getESXis) {
$printluns += Get-VMHost $getESXi | Get-ScsiLun -LunType disk |
Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath,
@{N='VM';E={$lunTab[$_.CanonicalName]}}
}
$printluns | Export-Csv "$FileCSV1" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Does this where-clause do the trick?
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns = @()
# Get all RDM luns and store with VM name
$lunTab = @{}
Get-VM -Location $getCluster -PipelineVariable vm |
Get-HardDisk | Where-Object { $_.DiskType -like “Raw*” } |
ForEach-Object -Process {
if($lunTab.ContainsKey($_.ScsiCanonicalName)) {
$lunTab[$_.ScsiCanonicalName] = $lunTab[$_.ScsiCanonicalName], $vm.Name -join '|'
}
else {
$lunTab.Add($_.ScsiCanonicalName,$vm.Name)
}
}
foreach ($getESXi in $getESXis) {
$printluns += Get-VMHost $getESXi | Get-ScsiLun -LunType disk |
where{$_.CommandsToSwitchPath -ne 200} |
Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath,
@{N='VM';E={$lunTab[$_.CanonicalName]}}
}
$printluns | Export-Csv "$FileCSV1" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try with
@{N="IOPS";E={Get-ScsiLun -CanonicalName $_.ScsiCanonicalName -LunType disk | Select-Object CommandsToSwitchPath}} |
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tried your suggestion and it's still blank on the IOPS column.
Get-VM | Sort-Object | Get-HardDisk | Where-Object {$_.DiskType -like “Raw*”} |
Select @{N=”VMName”;E={$_.Parent}},Name,DiskType,@{N=”LUN_ID”;E={$_.ScsiCanonicalName}},
@{N='SCSIid';E={$th = $_
$ctrl = $th.Parent.Extensiondata.Config.Hardware.Device | Where {$_.Key -eq $th.ExtensionData.ControllerKey}
"$($ctrl.BusNumber):$($_.ExtensionData.UnitNumber)"}},Filename,CapacityGB,@{N="IOPS";E={Get-ScsiLun -CanonicalName $_.ScsiCanonicalName -LunType disk | Select-Object CommandsToSwitchPath}} |
Export-Csv "C:\RDM_IOPS.csv" -NoTypeInformation
And with
@{N="IOPS";E={Get-ScsiLun -CanonicalName $_.ScsiCanonicalName -LunType disk | Select-Object -ExpandProperty CommandsToSwitchPath}} |
You are sure there is something in the CommansToSwitchPath property?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yea still blank on the IOPS column. I have this other script below that shows the CommandsToSwitchPath column but this one does not have the VM name like the RDM script that I'm trying to add the IOPS (CommandsToSwitchPath) column.
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns=@()
foreach ($getESXi in $getESXis)
{
$getLUNsforESXi = Get-VMHost $getESXi | Get-ScsiLun -LunType disk | Select VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath
$printluns = $printluns + $getLUNsforESXi
}
$printluns | Export-csv "$FileCSV1" -NoTypeInformation
Would there be an easier way to add the VMName column to this script instead?
You could try something like this
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns = @()
# Get all RDM luns and store with VM name
$lunTab = @{}
Get-VM -Location $getCluster -PipelineVariable vm |
Get-HardDisk | Where-Object { $_.DiskType -like “Raw*” } |
ForEach-Object -Process {
$lunTab.Add($_.ScsiCanonicalName,$vm.Name)
}
foreach ($getESXi in $getESXis) {
$printluns += Get-VMHost $getESXi | Get-ScsiLun -LunType disk |
Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath,
@{N='VM';E={$lunTab[$_.CanonicalName]}}
}
$printluns | Export-Csv "$FileCSV1" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I am getting the below error, while I execute the above script
That seems to indicate you have shared RDM, connected to multiple VMs.
Try this variation, it will show all VMs connected to a shared RDM LUN
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns = @()
# Get all RDM luns and store with VM name
$lunTab = @{}
Get-VM -Location $getCluster -PipelineVariable vm |
Get-HardDisk | Where-Object { $_.DiskType -like “Raw*” } |
ForEach-Object -Process {
if($lunTab.ContainsKey($_.ScsiCanonicalName)) {
$lunTab[$_.ScsiCanonicalName] = $lunTab[$_.ScsiCanonicalName], $vm.Name -join '|'
}
else {
$lunTab.Add($_.ScsiCanonicalName,$vm.Name)
}
}
foreach ($getESXi in $getESXis) {
$printluns += Get-VMHost $getESXi | Get-ScsiLun -LunType disk |
Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath,
@{N='VM';E={$lunTab[$_.CanonicalName]}}
}
$printluns | Export-Csv "$FileCSV1" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I was getting the below error
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:11 char:28
+ if($lunTab.ContainsKey(ScsiCanonicalName))
+ ~
Missing ')' in method call.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:11 char:28
+ if($lunTab.ContainsKey(ScsiCanonicalName))
+ ~~~~~~~~~~~~~~~~~
Unexpected token 'ScsiCanonicalName' in expression or statement.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:11 char:28
+ if($lunTab.ContainsKey(ScsiCanonicalName))
+ ~~~~~~~~~~~~~~~~~
Missing closing ')' after expression in 'if' statement.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:10 char:25
+ ForEach-Object -Process {
+ ~
Missing closing '}' in statement block or type definition.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:11 char:45
+ if($lunTab.ContainsKey(ScsiCanonicalName))
+ ~
Unexpected token ')' in expression or statement.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:11 char:46
+ if($lunTab.ContainsKey(ScsiCanonicalName))
+ ~
Unexpected token ')' in expression or statement.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:14 char:7
+ } else {
+ ~~~~
Unexpected token 'else' in expression or statement.
At D:\myreports\RDM_IOPS_Info\RDM_IOPS_Info.ps1:17 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
I changed the below line
if($lunTab.ContainsKey(ScsiCanonicalName)) {
To
if($lunTab.ContainsKey($_.ScsiCanonicalName)) {
Now, I am able to get the output but , CommandsToSwitchPath column shows blank
I also updated the typo in my code above.
No clue why that returns a blank in case of an RDM.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This script is awesome and is exactly what I was looking for! I hope others find this useful for their environments because this helps us report IOPS count for all of our RDM's. Thank you LucD!
Hi Luc, is there any way to make this report so it will only report if the IOPS count does NOT equal 200? I've been racking my brain around this for days and can't figure out how.
The reason for this report is because we use IOPS 200 based on VMware KB (Adjusting Round Robin IOPS limit from default 1000 to 1 (2069356) (vmware.com)) and we would like this report to let us know if anything is not set to 200.
Does this where-clause do the trick?
$getCluster = Get-Cluster
$getESXis = $getCluster | Get-VMHost
$printluns = @()
# Get all RDM luns and store with VM name
$lunTab = @{}
Get-VM -Location $getCluster -PipelineVariable vm |
Get-HardDisk | Where-Object { $_.DiskType -like “Raw*” } |
ForEach-Object -Process {
if($lunTab.ContainsKey($_.ScsiCanonicalName)) {
$lunTab[$_.ScsiCanonicalName] = $lunTab[$_.ScsiCanonicalName], $vm.Name -join '|'
}
else {
$lunTab.Add($_.ScsiCanonicalName,$vm.Name)
}
}
foreach ($getESXi in $getESXis) {
$printluns += Get-VMHost $getESXi | Get-ScsiLun -LunType disk |
where{$_.CommandsToSwitchPath -ne 200} |
Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath,
@{N='VM';E={$lunTab[$_.CanonicalName]}}
}
$printluns | Export-Csv "$FileCSV1" -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Outstanding! This was driving me crazy, thank you so much, it works great!