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