【发布时间】:2019-03-25 14:24:50
【问题描述】:
我创建了一个从本地电脑运行的脚本,并使用invoke-command 将文件从 Host-1 复制到 host-2。
相关部分:
$session =New-PSSession -Computername $Thost -Credential $mycreds
Invoke-Command -Session $session -ScriptBlock {
#seting a temp drive on Host for simple approch
Remove-PSDrive -Name w -Force
New-PSDrive -Name w -PSProvider FileSystem -Root $Using:VMPath -Credential $Using:mycreds -ErrorAction Stop
Write-Host "You Chose that $Using:OSVersion will be copyed to $Using:Thost"
Copy-Item -Path "w:\$Using:OSVersion" -Destination $using:VMXPath -Recurse
Remove-PSDrive -Name w -Force -ErrorAction Stop
}
我第一次运行脚本时运行良好! First Run of the Script
第二次说 PSdrive 不存在。 Second Run Error in PowerShell
10 分钟后 +- 脚本再次运行,没有任何问题
【问题讨论】:
标签: windows powershell vmware vmware-workstation