0
我读过,当您将它们传递到脚本块start-job
调用时序列化对象。这似乎对字符串和东西很好,但我试图通过一个xml.XmlElement
对象。我确定该对象是XMLElement
之前我调用脚本块,但在作业中,我得到此错误:将XmlElement传递到PowerShell后台作业
Cannot process argument transformation on parameter 'node'. Cannot convert the "[xml.XmlElement]System.Xml.XmlElement"
value of type "System.String" to type "System.Xml.XmlElement".
+ CategoryInfo : InvalidData: (:) [], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError
+ PSComputerName : localhost
那么,我该如何让我的XmlElement
回来。有任何想法吗?
对于它的价值,这是我的代码:
$job = start-job -Name $node.LocalName -InitializationScript $DEFS -ScriptBlock {
param (
[xml.XmlElement]$node,
[string]$folder,
[string]$server,
[string]$user,
[string]$pass
)
sleep -s $node.startTime
run-action $node $folder $server $user $pass
} -ArgumentList $node, $folder, $server, $user, $pass