Create variable names in Windows PowerShell scripts
You should create variable names that describe the data stored in them. For example, a variable that stores a user account could be $user, and a variable that stores the name of a log file could be $logFileName.
In most cases, you'll notice variables are used with a dollar sign ($) symbol. The $ symbol is not part of the variable name but it distinguishes variables from other syntax elements of PowerShell. For example, $user designates a variable named user, and the $ symbol helps PowerShell to identify that it's a variable.
You should typically limit variable names to alphanumeric characters (letters and numbers). While you can include some special characters and spaces, it becomes more confusing to use. For example, to include a space in a variable name, you need to enclose the name in braces ({ }). An example would be ${log File}, where there's a space between the words log and file.
Variable names aren't case sensitive. The variables $USER and $user are interchangeable. For improved legibility, the common convention is to use lowercase characters and capitalize the first letter of each word in a variable name. Capitalizing the first word is optional depending on the situation and your preferences. For example, $logFile and $LogFile are both commonly used. However, when variables are used for parameters in a script, the first word should be capitalized for consistency with the parameters used by cmdlets. Both camelCase ($logFileName) and underscore-separated ($log_file_name) conventions are valid and commonly used. Using a capital letter or an underscore acts as a separator between the words and makes the variable name more legible. Avoid spaces or hyphens in variable names, as those require enclosing the name in braces ({ }) or can cause parsing issues.