The syntax helps with evaluating the expression inside it.
$arr = @(1,2,3)
$msg1 = "$arr.length"
echo $msg1 # prints 1 2 3.length - .length was treated as part of the string
$msg2 = "$($arr.length)"
echo $msg2 # prints 3
You can read more at http://ss64.com/ps/syntax-operators.html
More Related Contents:
- PowerShell string interpolation syntax
- How can you use an object’s property in a double-quoted string?
- How do I pass multiple parameters into a function in PowerShell?
- Using a Variable (PowerShell) inside of a command
- how do I pass a range of values on the command line – passing an expression as an argument
- How do I do the bash equivalent of $PROGPATH/program in Powershell?
- PowerShell outputting array items when interpolating within double quotes
- PowerShell’s parsing modes: argument (command) mode vs. expression mode
- ‘kubectl patch’ works on Linux Bash but not in Windows Powershell ISE
- Powershell color formatting with format operator
- Convert a batch-file command with complex arguments to PowerShell
- DateTime subtraction not working in PowerShell – assignment vs. equality operator
- Create an incrementing variable from 2 variables in PowerShell
- Using expanding strings as Powershell function parameters
- Powershell Formatting for a String
- Is there a powershell pattern for if($?) { }
- this code my teacher gave it to us as homework and it does not work with me idk why
- How can I write/create a powershell script verbatim, from another powershell script?
- How do I pass variables with the Invoke-Command cmdlet?
- Powershell equivalent of bash ampersand (&) for forking/running background processes
- Why does ‘continue’ behave like ‘break’ in a Foreach-Object?
- Why don’t .NET objects in PowerShell use the current directory?
- How remove accents in PowerShell?
- Is there a way to pass serializable objects to a PowerShell script with start-process?
- How to use PowerShell copy-item and keep structure
- CMD or Powershell command to combine (merge) corresponding lines from two files [duplicate]
- How to download the SSL certificate from a website using PowerShell?
- Rename file on FTP with PowerShell
- Difference between PowerShell Console and PowerShell ISE
- Strange behavior for PowerShell Length after ForEach method