VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

Create VMs from a Template

HI

I'm trying to deploy Vms from a template and select a specific LUN from my datastore cluster. How can the code below be modified to accomplish this?

Thanks

$VMs = Get-Content "VmNames.txt"

$SourceTemp = "WIn2k08-R2"

$DsCluster = "DS-Cluster01"

$Folder = "Win2K08"

Foreach ($VM in $VMs) {

New-VM -Name $VMs -Template $SourceTemp -Datastore $DsCluster -Location $folder

}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Do you mean a specific datastore from that datastorecluster ?

If yes, you can just pass the datastorename on the Datastore parameter


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

Do you mean a specific datastore from that datastorecluster ?

If yes, you can just pass the datastorename on the Datastore parameter


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

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Yes I do mean a specific datastore from the datastore cluster but the datstores within the datastore clusters are not unique only the datastore cluster names within my environment. Can this still work?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

How do you mean "not unique" ?

Then how do you select the datastore ?

Is that where the LUN comes in ?


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

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

If I understand you correctly do you mean to specify the datastore name and PowerCLI will know to find the datastore that I specify in the Datastore Cluster? For ex.

-Datastore -Name Datastore01

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I mean one of the names that are returned by this

Get-DatastoreCluster -Name DS-Cluster01 | Get-Datastore | Select Name


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

0 Kudos