Hi guys. I'm trying to get this modified script to disable "delayed ack" on every esxi host in a cluster. With the original script, it only targets specific esxi hosts instead and it runs just fine. When it runs this way (i.e. specifying the cluster so it iterates through the hosts one at a time), it fails on the first host it attempts to process. The error message has been provided below. Could someone tell me why it's not working and / or help fix it?
=================Error Message============
Exception calling "UpdateInternetScsiAdvancedOptions" with "3" argument(s): "The object or item referred to could not be found."
At line:52 char:1
+ $HostStorageSystem.UpdateInternetScsiAdvancedOptions($HostiSCSISoftwa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
=================Script====================
param (
[parameter(Mandatory=$true
,HelpMessage="VC Name")]
[string] $VC
,[parameter(Mandatory=$true
,HelpMessage="Cluster Name")]
[string] $cluster
)
$svr=$null;
$svr = Connect-VIServer -Server $VC;
if ($svr -eq $null)
{
$sMsg = "Unable to connect to VC " + $VC;
exit 1;
}
$sMsg = "Getting cluster " + $cluster +" on VC " + $VC;
Write-Host $sMsg;
$oClstr=$null;
$oClstr = Get-Cluster -Server:$svr -Name $cluster;
if ($oClstr -eq $null)
{
$sMsg="Unable to find cluster " +$cluster + " on VC " + $VC;
$iret1 = Disconnect-VIServer -Server:$svr -Confirm:$false -ErrorAction:SilentlyContinue;
exit 1;
}
$sMsg ="Getting hosts on cluster " + $cluster + " on VC " + $VC;
write-host $sMsg;
$hosts = Get-VMHost -Location $oClstr -Server:$svr;
foreach($item in $hosts)
{
$sMsg = "Processing host " + $item.Name + " in cluster " +$cluster + " on VC " +$VC;
write-host $sMsg;
}
$HostView = Get-VMHost $hosts | Get-View
$HostStorageSystemID = $HostView.configmanager.StorageSystem
$HostiSCSISoftwareAdapterHBAID = ($HostView.config.storagedevice.HostBusAdapter | where {$_.Model -match "iSCSI Software"}).device
$options = New-Object VMWare.Vim.HostInternetScsiHbaParamValue[] (1)
$options[0] = New-Object VMware.Vim.HostInternetScsiHbaParamValue
$options[0].key = "DelayedAck"
$options[0].value = $false
$HostStorageSystem = Get-View -ID $HostStorageSystemID
$HostStorageSystem.UpdateInternetScsiAdvancedOptions($HostiSCSISoftwareAdapterHBAID, $null, $options)