expirat001
expirat001

Reputation: 2225

What is the name of this Powershell syntax?

Let's that as an example this query :

Get-ADGroup $group -Properties Name | Select-Object Name

I don't remember the name of the following syntax in Powershell to get an attribute through parenthesis, it came since v2 I guess.

(Get-ADGroup $group -Properties Name).Name

Upvotes: 0

Views: 360

Answers (2)

FoxDeploy
FoxDeploy

Reputation: 13567

It's called a subexpression.

Use a subexpression to return specific properties of an object.

As seen in this page on ss64.com

Dot notation or dot-sourcing refers to adding a dot before the path to execute a script found in the same folder. For instance, if you wanted to run MyScript.ps1 and it is found in your current directory, you can't just type MyScript.ps1. PowerShell's security policy requires you to specify the full path, or use the full-path shortcut of:

.\MyScript.ps1

Turns out I was wrong:

According to Bruce Payette, head developer of PowerShell in his book PowerShell in Action(Chapter 5 Advanced Operators and Variables, page 132), the '.' character in PowerShell is the 'property dereference operator'.

He also calls it the dot operator, so it doesn't seem like it has a special name other than 'property dereference operator'.

I'd never heard that phrase before, but decided that I had to know after all of this conversation here.

Upvotes: 1

Frode F.
Frode F.

Reputation: 54981

Do you mean Dot notation\Dotted notation? That's the "process" of accesing the property in the object.

The parentheses around is a c#/.Net technique to specify the order to run the code in a line, but I'm not sure what the official name is. Expression operator or () operator I guess.

You can use enclosures, such as parentheses, to override the standard precedence order and force Windows PowerShell to evaluate the enclosed part of an expression before an unenclosed part.

Source: about_Operator_Precedence

Upvotes: 2

Related Questions