0

I ran the following very simple command in powershell. However it does not seem to be working:

If("2f7c654f-16ce-46d8-a037-9827916ba655_opt.script" -contains "2f7c654f-16ce-46d8-a037-9827916"){"hi"} 

Can someone please guide me as to where am I going wrong

0

1 Answer 1

2

the -contains operator is an array operator, not a string operator. it tests for an exact match with one or more items in an array. that is a really common mistake. [grin]

you want the .Contains() string method.

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

2 Comments

or -like with wildcards
@OwainEsau - yep ... but the OP had a very direct problem with the two contains versions, so that is all i mentioned. i am always uncertain how much extra info to give ...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.