使用Powershell 3.0:
Name Value
---- -----
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18444
BuildVersion 6.2.9200.16481
PSCompatibleVersions {1.0, 2.0, 3.0}
PSRemotingProtocolVersion 2.2
从VM_Backup.ps1内部调用时,使用New-PSDrive未正确映射网络驱动器:
MonitorFramework.ps1:
workflow Monitoring_Local {
parallel{
InlineScript{$run = VM_Backup.ps1}
}
}
VM_Backup.ps1:
$cred = REDACTED
Connect-VIServer -server "x.x.x.x" -Credential $cred
$sourcedatastore = Get-Datastore “datastore1”
$destinationdatastore = Get-Datastore “nas02”
New-PSDrive -Location (Get-Datastore “datastore1”) -Name source_datastore -PSProvider VimDatastore -Root “”
New-PSDrive -Location ( Get-Datastore “nas02”) -Name destination_datastore -PSProvider VimDatastore -Root “”
Get-PSDrive
Get-PSDrive的输出将显示上面的驱动器尚未映射。
当我直接运行VM_Backup.ps1脚本(不通过MonitorFramework.PS1调用)时,驱动器已正确映射。
任何帮助/见解/建议都会非常感激!