gpt4 book ai didi

Powershell - 无法验证参数 'Name' 的参数。参数中的字符数 (0) 太少

转载 作者:行者123 更新时间:2023-12-03 00:21:30 25 4
gpt4 key购买 nike

这是我使用 powershell 脚本的第一天我正在尝试使用 VMM Cmdlet Get-SCVirtualMachine当我像

这样使用它时它工作正常
PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"

但是当我尝试的时候它给了我一个错误

PS C:\> $vmName = 'VM01'
PS C:\> $VM = Get-SCVirtualMachine -Name "$vmName"

我得到的错误是

Cannot validate argument on parameter 'Name'. The number of characters (0) in the argument is too small. Specify an argument whose length is greater than or equal to "1" and then try the command again.

谁能告诉我我做错了什么?

谢谢

最佳答案

该命令看起来不错,应该可以工作。您是将错误作为脚本的一部分还是仅通过您发布的示例?

您提到您正在使用 Get-SCPerformanceData cmdlet,而您的示例使用了另一个 cmdlet。

尝试从参数中删除引号,有帮助吗?

关于Powershell - 无法验证参数 'Name' 的参数。参数中的字符数 (0) 太少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12302503/

25 4 0