Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need a string with a $ in powershell inside ' '

I am trying to write a PS script to find a share named C$$ but PS is interpreting the $ sign and I want to pass it into the filter. Normally \ stops this but after googling I cant get a working solution.

$string = "Name='C\$\$'"
Write-Host $string
get-wmiobject -Class Win32_share -filter $string

The write host returns Name='C\$\$' I need it to return C$$

like image 786
Andyg_2020 Avatar asked Mar 25 '26 14:03

Andyg_2020


1 Answers

You can use the backtick to escape characters in a string.

$string = "Name='C`$`$'"

That should return Name='C$$'

like image 107
Bryce McDonald Avatar answered Mar 28 '26 10:03

Bryce McDonald



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!