Case-insensitive PowerShell replacement

Call me pedantic but while nobody here was outright wrong, nobody provided the correct code for the final solution either.

You need to change this line:

$NullSessionPipes =  $NullSessionPipes.replace("browser", "")

to this:

$NullSessionPipes =  $NullSessionPipes -ireplace [regex]::Escape("browser"), ""

The strange [regex] text isn’t strictly necessary as long as there are no regular expression characters (ex. *+[](), etc) in your string. But you’re safer with it. This syntax works with variables too:

$NullSessionPipes =  $NullSessionPipes -ireplace [regex]::Escape($stringToReplace), $stringToReplaceItWith

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)