【问题标题】:vmware powerclivmware powercli
【发布时间】:2015-03-11 22:24:26
【问题描述】:

我想从多个模板创建新的虚拟机,比如 windows 8,7 等等,还想选择我需要多少个虚拟机。

完整代码在这里: link to pastebin

但问题是我想一次做多个模板,我该怎么做?

我在考虑一个 foreach($template in $template){do that}

然后我在做模板1,模板2,但它给了我一个错误,它只是模板1,模板2而不是2个不同的模板不知道如何分开。我想过,但我当时不知道。

【问题讨论】:

  • 您有多个模板,想为每个模板创建一个虚拟机,对吧?
  • 我想从一个模板创建多个虚拟机,我想为此使用多个模板
  • 它现在是如何工作的,我可以创建多个虚拟机,但不能使用多个模板,我也使用了拆分,但虚拟机名称没有改变
  • 找不到它需要静止的方式:(
  • 如果您编辑问题以包含 mcve 以及完整的错误文本,人们可能会仔细观察。

标签: powershell powercli


【解决方案1】:

这是不可能的,您必须指定一个(并且只有一个)模板才能从模板创建一个新模板。

您可以通过运行以下命令来验证:

Get-Help New-VM -Parameter Template

-Template <Template>
    Specifies the virtual machine template you want to use for the creation of the new virtual machine. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.

    Required?                    true
    Position?                    2
    Default value
    Accept pipeline input?       true (ByValue)
    Accept wildcard characters?  true

如你所见,这个 -Template 参数只接受一个 [Template] 类型的对象。 如果它能够采取几个,我们会看到:

-Template <Template[]>

但无论如何在 GUI 中都是一样的:在 vSphere 客户端中,您只需选择一个模板即可从中创建虚拟机。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多