VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Set Queue Depth to all the devices

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)"

        }

    }

}

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

$match = '^naa.634532'

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

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

$match = '^naa.634532'

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

ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect. Thank you LucD. That worked Smiley Happy

0 Kudos
CS026
Contributor
Contributor
Jump to solution

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"

}

}

}

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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