powershell vmware强力客户端

uinbv5nw  于 2022-12-23  发布在  Shell
关注(0)|答案(1)|浏览(110)

我想创建新的虚拟机的从多个模板的像Windows 8,7和更多类似的,也想选择有多少我需要的虚拟机。
完整代码如下:link to pastebin
但问题是我想一次做多个模板,我怎么能做到呢?
我在考虑foreach($模板中的$模板){这样做}
然后我做模板1,模板2,但它给我的错误,它只是模板1,模板2,而不是2个不同的模板不知道如何分离。我想过,但我不知道然后。

4c8rllxm

4c8rllxm1#

这是不可能的,您必须指定一个(且只能指定一个)模板才能从模板创建新模板。
您可以通过运行以下命令进行验证:

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客户端中,您只需选择一个模板即可从中创建虚拟机。

相关问题