VMware Cloud Community
admin
Immortal
Immortal

How to create datastore use canonicalname

I want to create datastore DS100 and later use following script. where is my fault?

Thanks a lot.

XiongYe

$x=100

foreach ($DS in (Get-vmhost vm-hostname|get-scsilun –luntype disk |select canonicalname)){

New-Datastore -VMHost prme-erqa-002.eng.vmware.com -Name DS-$x -Path $DS

$x=$x+1

}

Tags (1)
0 Kudos
5 Replies
LucD
Leadership
Leadership

Try changing

foreach ($DS in (Get-vmhost vm-hostname|get-scsilun –luntype disk |select canonicalname)){

into

foreach ($DS in (Get-vmhost vm-hostname|get-scsilun –luntype disk |select -ExpandProperty canonicalname)){


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
admin
Immortal
Immortal

Sorry not work...

0 Kudos
LucD
Leadership
Leadership

Does

Get-vmhost vm-hostname|get-scsilun –luntype disk |select -ExpandProperty canonicalname

return anything ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
admin
Immortal
Immortal

it return  device name which could be used to create datastore, but error not caused by this.

lun.jpg

0 Kudos
LucD
Leadership
Leadership

What error message are you getting on the New-Datastore cmdlet ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos