I'm trying to configure SIOC statistics collection for several NFS volume via powercli
The setting I'd like to configure is the following

I found a script on one thread that could be adapted but I found it not working
Here is the script
$si = Get-View ServiceInstance
$storMgr = Get-View -Id $si.Content.StorageResourceManager
$spec = New-Object VMware.Vim.StorageIORMConfigSpec
$spec.Enabled = $false
$spec.StatsAggregationDisabled = $true
$spec.StatsCollectionEnabled = $false
foreach($ds in (Get-View -ViewType Datastore -Filter @{'Summary.MultipleHostAccess'='True'})){
Write-Output "Configuring datastore $($ds.Name)"
$storMgr.ConfigureDatastoreIORM($ds.MoRef,$spec)
}
the error I got is the following
Exception calling "ConfigureDatastoreIORM" with "2" argument(s): "Datastore '' is not accessible. No connected and
accessible host is attached to this datastore."
At C:\Scripts\Definitivi\SetSIOC.ps1:95 char:5
+ $storMgr.ConfigureDatastoreIORM($ds.MoRef,$spec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException