VMware Cloud Community
malabelle
Enthusiast
Enthusiast

new datastore set the prefered path?

Hi,

I have a script to create new datastore. nut I can't find how to specify the prefered path (hba:x:x...)

any idea?

Add-PSSnapin "Vmware.VimAutomation.Core"
## ----Créer les  Variables----
#$vcenter = %1
## ----Connexion au VirtualCenter----
$Server = $Args[0]
$ClusterName = $Args[1]
Connect-VIserver $Server
$VMHost = Get-Cluster $ClusterName | Get-VMHost | Select -First 1
$VMHostRes = Get-Cluster $ClusterName | Get-VMHost
$Name = $Args[2]
$Path = $Args[3]
Get-VMHost $VMHost | New-Datastore -Server $Server -Name $Name -Path $Path -Vmfs -Confirm:$false
Get-VMHostStorage -VMHost $VMHostRes -Refresh
vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos
3 Replies
kjb007
Immortal
Immortal

You don't set preferred path on a datastore, per se, you se it on the LUN or LUNs that make up that datastore.  You'll need to use set-scsilun to do that.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
malabelle
Enthusiast
Enthusiast

ok, so I would need to add something like that after the rescan

?

Get-SCSILUN -CanonicalName args1 -vmhost args2 | SetSCSILun -PreferredPath args3 confirm:$false

vExpert '16, VCAP-DCA, VCAP-DCD
0 Kudos
kjb007
Immortal
Immortal

As long as you have those arguments handy, then yes, that's what you'll need to do.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB