Powershell | adding double quotation to a string

Viewed 35

I want to print a variable with double quotation but Powershell automatically print without them so anyone knows?

for example print = mobile number is: "9847636782" << I want to print the number with the double quotation

I have tried this way : write-host "mobile number is: "$mobilenum" "

and didn't work so please help

1 Answers
Write-Host "mobile number is: `"$mobilenum`""

enter image description here

Please find detailed information about escaping here.

Finally, if your PowerShell strings are quoted with double quotes, then any double quote characters in the string must be escaped with the backtick "`". Alternatively, the embedded double quote characters can be doubled (replace any embedded " characters with "").

enter image description here

Related