I'm a noob at this, just testing the PowerShell CLI to see if we can automate some basic tasks. Have one issue when deploying a vm using New-VM. if the target datastore is available to more than one cluster, the -Datastore parameter fails, stating that its getting more than one parameter, even when explicity entering the DS name. For example:
new-vm -VMhost hostname -Name vmname -template templatename -datastore DSname
returns:
New-VM : 2/10/2010 1:38:12 PM New-VM The specified parameter 'Datastore' expects a single value, but your name criteria 'DSname'
corresponds to multiple values.
If i change the DS to point to local storage on a server, it runs fine.
Issuing a "Get-Datastore DSName" yields this:
Name FreeSpaceMB CapacityMB
-
-
-
DSname 154411 511744
DSname 162610 511744
This is a lab setup, with two clusters sharing the same LUNs.
If I target a LUN in a cluster that is not shared, it works fine as well. Get-Datastore only returns the DSname once
Is there anyway to work around this?
Thx in advance.
Do I see this correctly that you have 2 datastores with the same name in those 2 clusters ?
That is, afaik, not a good practice.
And you have 2 clusters sharing the same LUN.
I'm not sure that is a good practice either.
In any case, to get at a specific datastore you can select it explicitly.
Something like this for example
$esx = Get-VmHost hostname $ds = $esx | Get-Datastore DSname new-vm -VMhost $esx -Name vmname -template templatename -datastore $ds
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Do I see this correctly that you have 2 datastores with the same name in those 2 clusters ?
That is, afaik, not a good practice.
And you have 2 clusters sharing the same LUN.
I'm not sure that is a good practice either.
In any case, to get at a specific datastore you can select it explicitly.
Something like this for example
$esx = Get-VmHost hostname $ds = $esx | Get-Datastore DSname new-vm -VMhost $esx -Name vmname -template templatename -datastore $ds
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thx for the response..yes I figured it wasn;t good practice (not the owner, and it is a lab setup). I'll give that a shot.
Just to clarify, datastores are shared across the clusters, there are not multiple datastores with the same name.
Thx again
Worked like a champ, thanks!