Hi,
I've been using the following script to set datastores to FIXED path. Because we are using a stretch cluster, each datastore can connect to 2 of 4 paths. We additionally load balance over both fabrics. So even named hosts will use the path to fabric A and odd named hosts will use the path to fabric B.
get-scsilun -vmhost esx01* | Get-Scsilunpath -ScsiLun { $_ } | where { $_.SanID -eq "20:00:00:00:00:00:00:01" -or $_.SanID -eq "20:00:00:00:00:00:10:02" } | Set-Scsilunpath -scsilunpath { $_ } -preferred
get-scsilun -vmhost esx02* | Get-Scsilunpath -ScsiLun { $_ } | where { $_.SanID -eq "20:00:00:00:00:00:00:03" -or $_.SanID -eq "20:00:00:00:00:00:10:04" } | Set-Scsilunpath -scsilunpath { $_ } -preferred
The script works fine, however, it targets all datastores on each host which have been previously set, not just new ones. How can I adjust it to target only new datastores by name?
Thanks!
You could expand the Where-clause and only take the paths that not set as preferred.
Get-ScsiLun -VmHost esx01* |
Get-Scsilunpath |
where { ($_.SanID -eq "20:00:00:00:00:00:00:01" -or $_.SanID -eq "20:00:00:00:00:00:10:02") -and -not $_.Preferred} |
Set-Scsilunpath -Preferred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could expand the Where-clause and only take the paths that not set as preferred.
Get-ScsiLun -VmHost esx01* |
Get-Scsilunpath |
where { ($_.SanID -eq "20:00:00:00:00:00:00:01" -or $_.SanID -eq "20:00:00:00:00:00:10:02") -and -not $_.Preferred} |
Set-Scsilunpath -Preferred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference