0

I am new to Powershell and I have a question.

$status = @(qlist job -jt backup -co s)
Write-Host $status[3]
$status[3] -ceq "Suspended"

The answer is

 Suspended
False

My question is: Why is this comparison false?

1 Answer 1

1

Looks like you have an extra space in $status[3]

" Suspended" -eq "Suspended" 
False

you may try:

" Suspended" -like "*Suspended*" 
True

Parameter -ceq means case sensitive equal, so use only if really needed. Equivalent for case sensitivity like is -clike

P.S. Also another option would be to use the trim method, which will remove the empty spaces: $status[3].trim() -eq "Suspended"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.