Я написал скрипт для получения ресурсов автономного кластера с использованием синтаксиса foreach
, и он работает нормально.Но мне нужно получить кластерные автономные ресурсы для 50 кластеров, и я попытался foreach -parallel
и получил ошибку.
workflow Test-Workflow {
Param ([string[]] $clusters)
$clusters = Get-Content "C:\temp\Clusters.txt"
foreach -parallel ($cluster in $clusters) {
$clu1 = Get-Cluster -Name $cluster
$clustername = $clu1.Name
echo $clustername
$clu2 = Get-Cluster $clustername |
Get-ClusterResource |
where { $_.Name -and $_.state -eq "offline" }
echo $clu2
}
}
Test-Workflow
Вывод:
slchypervcl003
slchypervcl004
Get-ClusterResource : The input object cannot be bound to any parameters for
the command either because the command does not take pipeline input or the
input and its properties do not match any of the parameters that take pipeline
input.
At Test-Workflow:8 char:8
+
+ CategoryInfo : InvalidArgument: (slchypervcl003:PSObject) [Get-ClusterResource], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.FailoverClusters.PowerShell.GetResourceCommand
+ PSComputerName : [localhost]
Get-ClusterResource : The input object cannot be bound to any parameters for
the command either because the command does not take pipeline input or the
input and its properties do not match any of the parameters that take pipeline
input.
At Test-Workflow:8 char:8
+
+ CategoryInfo : InvalidArgument: (slchypervcl004:PSObject) [Get-ClusterResource], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.FailoverClusters.PowerShell.GetResourceCommand
+ PSComputerName : [localhost]