Powershell Best Practice #13: Avoid double quotes in strings if not necessary

Best Practice: It is recommended to use single quotes if there are no variables or escape sequences in strings, otherwise, you should use double quotes.

Single quotes

PowerShell

1

2

# Literal string (there is no variable inside, it is "text only")

$computerName='server01'

Double quotes

PowerShell

1

2

# Expanding string (there is a variable inside: $i)

$computerName="server$i"

Explanation: Single quotes disable the expansion of variables and should be preferred if there is no variable or escape sequence inside strings to reduce unexpected results (ex: if the string contains dollar sign $, etc.).