【发布时间】:2017-06-06 09:29:22
【问题描述】:
我目前正在开发一个脚本,它应该能够将某个 Windows 共享作为网络驱动器附加到主机系统中,并带有驱动器号。由于 Windows 共享是动态的(几乎在脚本被调用的所有时间都可能发生变化。)我需要将此作为参数传递给在 VM 上运行的脚本。
我目前拥有的。
在我的脚本中调用存储在我机器上的脚本。
MainScript.ps1 包含。
$MyVMName = "somevmname"
$Script = "C:\path\to\script\somescript.ps1 -Path \\some\shared\folder"
Invoke-VMScript -VM $MyVMName -ScriptText $Script -ScriptType PowerShell -GuestCredential $MyGuestCredential
somescript.ps1 包含。
Param(
[Parameter(Mandatory=$true)]
$Path,
[Parameter(Mandatory=$true)]
$Credentials
)
New-PSDrive -Name "H" -PSProvider FileSystem -Root $Path -Credential $Credentials
每次我执行 MainScript.ps1 时,它很可能会在执行 Invoke-VMScript 命令时冻结。是否有其他方法可以将参数传递给脚本?
在
下找到的文档https://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.powercli.cmdletref.doc/Invoke-VMScript.html
不会透露太多调用脚本的使用参数。
【问题讨论】:
标签: powershell powercli