I need a powershell script which gets information from another powershell script.
It seems to me the it is an array what I get in my script, so I tried to compare one item or the whole array against a string.
I will execute then this command on our Exchange cluster:
Get-ClusterResource |fl State|.\CheckDAG1.ps1
The first script is an inbuild Exchange script to get the state of a fileshare witness, the second script is mine and looks like this:
Param (
[parameter(ValueFromPipeline=$True)]
[string[]]$Status
)
echo $Input.count
echo $Input
if ($input[2] -contains "Online") {
echo "1"}
else {
echo "0"}
The output is this:
5 State : Online 0
So I can see that the array has 5 items, item 2 is the written line, but the result is 0
.
What can I do so that the result is 1
as I expect?