Hi,
How can I modify the below script to set the queue depth to all the devices with the matching naa.634532* without the text file input
Please help
Script
Get-VMHost 10.10.12.24 -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
Import-Csv -Path .\naa.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
try{
$lun = $esxcli.storage.core.device.list.Invoke(@{device="$($row.CanonicalName)"})
if($lun.NoofoutstandingIOswithcompetingworlds -ne 128){
$newValue = @{
device = "$($row.CanonicalName)"
schednumreqoutstanding = 128
}
$esxcli.storage.core.device.set.Invoke()
Write-Host "LUN $($row.CanonicalName) on $($esx.Name) outstanding IO value set to 128"
}
else{
Write-Host "LUN $($row.CanonicalName) on $($esx.Name) already has outstanding IO value of 128"
}
}
catch{
Write-Host "LUN $($row.CanonicalName) not found on $($esx.Name)"
}
}
}
Try something like this
Get-VMHost 10.10.12.24 -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.list.Invoke() | where{$_.Device -match $match} |
ForEach-Object -Process {
if($_.NoofoutstandingIOswithcompetingworlds -ne 128){
$newValue = @{
device = "$($_.Device)"
schednumreqoutstanding = 128
}
$esxcli.storage.core.device.set.Invoke($newValue)
Write-Host "LUN $($_.Device) on $($esx.Name) outstanding IO value set to 128"
}
else{
Write-Host "LUN $($_.Device) on $($esx.Name) already has outstanding IO value of 128"
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-VMHost 10.10.12.24 -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.list.Invoke() | where{$_.Device -match $match} |
ForEach-Object -Process {
if($_.NoofoutstandingIOswithcompetingworlds -ne 128){
$newValue = @{
device = "$($_.Device)"
schednumreqoutstanding = 128
}
$esxcli.storage.core.device.set.Invoke($newValue)
Write-Host "LUN $($_.Device) on $($esx.Name) outstanding IO value set to 128"
}
else{
Write-Host "LUN $($_.Device) on $($esx.Name) already has outstanding IO value of 128"
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect. Thank you LucD. That worked
Thank you for this script! I'm trying to make a few adjustments and am running into issues. This is on vCenter version 6.7.
Rather than connecting to a single ESXi host, I'd like to connect to vCenter and have it loop through all hosts & devices.
I'd also like to check/change the Max Queue Depth setting.
Thanks for any help!
This code below is an example of what I'm trying to do and isn't working. For example I can't figure out where to put the "-PipelineVariable" or if it's needed.
$EsxHosts = Get-VMHost
foreach($EsxHost in $EsxHosts){
$esxcli = Get-VMHost $EsxHost | Get-EsxCli -V2
}
ForEach-Object -Process {
$esxcli.storage.core.device.list.Invoke() |
ForEach-Object -Process {
if($_.NoofoutstandingIOswithcompetingworlds -ne 30){
$newValue1 = @{
device = "$($_.Device)"
schednumreqoutstanding = 30
}
$esxcli.storage.core.device.set.Invoke($newValue1)
Write-Host "LUN $($_.Device) on $($esx.Name) Max Outstanding IO value set to 30"
}
else{
Write-Host "LUN $($_.Device) on $($esx.Name) already has a Max Outstanding IO value of 30"
}
}
ForEach-Object -Process {
if($_.DeviceMaxQueueDepth -ne 30){
$newValue2 = @{
device = "$($_.Device)"
maxqueuedepth = 30
}
$esxcli.storage.core.device.set.Invoke($newValue2)
Write-Host "LUN $($_.Device) on $($esx.Name) Max Queue Depth value set to 30"
}
else{
Write-Host "LUN $($_.Device) on $($esx.Name) already has a Max Queue Depth value of 30"
}
}
}
If you just leave out the ESXi name and remove the Where-clause, it looks at all ESXi nodes and all storage devices.
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.list.Invoke() |
ForEach-Object -Process {
if($_.NoofoutstandingIOswithcompetingworlds -ne 128){
$newValue = @{
device = "$($_.Device)"
schednumreqoutstanding = 128
}
$esxcli.storage.core.device.set.Invoke($newValue)
Write-Host "LUN $($_.Device) on $($esx.Name) outstanding IO value set to 128"
}
else{
Write-Host "LUN $($_.Device) on $($esx.Name) already has outstanding IO value of 128"
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference