Page 1 of 1

Rescan Script Errors (PowerShell)

Posted: Fri Mar 01, 2019 2:37 pm
by VirtyManWinds
Hi All,

I'm getting some errors recently on the Powershell Rescan Script.

I'm using PowerCLI 11 and ESXi 6.7U1. It's failing when it tires to set the IOPS on the RR:
Response status code does not indicate success: 500 (Internal Server Error).
At C:\rescan_script.ps1:15 char:1
+ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(0,$null,$CN.Canon ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ViError
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError
I may have copy/pasted an old version of the script from the web site. Here is my script:

Code: Select all

Import-Module VMware.PowerCLI
$counter = 1
if ($counter -eq 0){
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false | Out-Null
}
$ESXiHost = "xxxx"
$ESXiUser = "xxxxx"
$ESXiPassword = "xxxx"
Connect-VIServer $ESXiHost -User $ESXiUser -Password $ESXiPassword | Out-Null
Get-VMHostStorage $ESXiHost -RescanAllHba | Out-Null
Get-ScsiLun -VMHost $ESXiHost -LunType disk | Where-Object Vendor -EQ "STARWIND"|Where-Object ConsoleDeviceName -NE " " | Set-ScsiLun -MultipathPolicy RoundRobin |Out-Null
$StarwindCN = Get-ScsiLun -VMHost $ESXiHost -LunType disk |Where-Object Vendor -EQ "STARWIND" | Where-Object ConsoleDeviceName -NE " " | Select-Object CanonicalName
$esxcli = Get-EsxCli -VMHost $ESXiHost
foreach($CN in $StarwindCN){
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(0,$null,$CN.CanonicalName,1,"iops",0) | Out-Null
}
Disconnect-VIServer $ESXiHost -Confirm:$false
$file = Get-Content "$PSScriptRoot\rescan_script.ps1"
if ($file[1] -ne "`$counter = 1") {
$file[1] = "`$counter = 1"
$file > "$PSScriptRoot\rescan_script.ps1"
}
Any help would be awesome!

Re: Rescan Script Errors (PowerShell)

Posted: Fri Mar 01, 2019 3:12 pm
by Oleg(staff)
Please check this script:

Code: Select all

Import-Module VMware.PowerCLI
$counter = 0
if ($counter -eq 0){
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false|
Out-Null
}
$ESXiHost = "host_IP"
$ESXiUser = "user"
$ESXiPassword = "password"
Connect-VIServer $ESXiHost -User $ESXiUser -Password $ESXiPassword | Out-Null
Get-VMHostStorage $ESXiHost -RescanAllHba | Out-Null
Get-ScsiLun -VMHost $ESXiHost -LunType disk | Where-Object Vendor -EQ "STARWIND"|
Where-Object ConsoleDeviceName -NE " " | Set-ScsiLun -MultipathPolicy RoundRobin -CommandsToSwitchPath 1 |
Out-Null
Disconnect-VIServer $ESXiHost -Confirm:$false
$file = Get-Content "$PSScriptRoot\rescan_script.ps1"
if ($file[1] -ne "`$counter = 1") {
$file[1] = "`$counter = 1"
$file > "$PSScriptRoot\rescan_script.ps1"
}

Re: Rescan Script Errors (PowerShell)

Posted: Fri Mar 01, 2019 8:27 pm
by VirtyManWinds
That worked great! Thank you!

It set the RoudRobin and IOPS RR to 1 perfectly.

For reference I was using this guide that had the outdated script: https://www.starwindsoftware.com/resour ... sphere-6-5

I suppose they changed the API command is why it was erroring out.

Re: Rescan Script Errors (PowerShell)

Posted: Sun Mar 03, 2019 8:25 am
by Oleg(staff)
Thank you for confirmation.
Correct, there were some changes in ESXi 6.7, we will update the information in the documentation.