Poweshell escaped wildcard

I'm trying to compare string which contains wildcard character.

("www.mysite.*" -match '`*')  

But something is not working because I always get a True response, for example

("www.mysite.com" -match '`*') 

I've tried using -contains instead, but i get always false.


Solution 1:

You don't actually want to escape your wildcard character. Because then you just end up comparing to the wildcard character, while what you want to do is find out if your string contains an asterisk.

The way to do this is by matching on a regular expression.

'www.website.*' -match '\*'