I have written a script to get the offline cluster resources using foreach syntax and it is working fine. But I need to get the cluster offline resources for 50 clusters and I have tried foreach -parallel and got an error.
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
Output:
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]