# Punctuation Help: $\_. AND Dot Operator AND Fallback Dot Operator

**URL:** <https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496>\
**Category:** PowerShell Help\
**Created:** [January 18, 2021, 12:26pm UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496 "2021-01-18T12:26:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenray](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@stephenray](https://forums.powershell.org/u/stephenray)\
**Post date:** [January 18, 2021, 12:26pm UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496/1 "2021-01-18T12:26:57Z")

</div>

I finally understand this code pasted below from

Learn Windows PowerShell in a Month of Lunches Third Edition, Page 114

But I have seen other code like this, directly below. What’s that Dot? Or Period?

Is it a Dot Operator? Is it a Fallback Dot Operator?

Where can I read about how this works?

```
$names | foreach { "$_ = $($obj.$_)" }
```

And

```
$names = ( $obj | Get-Member -Type property l*).name
```

And

```
$names.foreach{ "$_ = $($obj.$_)" }
```

The above is from Windows Powershell In Action, Third Edition, P. 136-137

Code pasted below is from:

Learn Windows PowerShell in a Month of Lunches Third Edition, Page 114

Input CSV File

login dept city title

DonJ IT Las Vegas CTO

Gregs Custodial Denver Janitor

JeffM IT Syracuse Network Engineer

I understand the $_. very well from the book. Does this $_. have a name? I want to read more about it somewhere.

```
PS C:\WINDOWS\system32> import-csv c:\Homeuse\newusers.csv |
select-object -property *,
@{name='samAccountName';expression={$_.login}},
@{label='Name';expression={$_.login}},
@{n='Department';e={$_.Dept}}

login : DonJ
dept : IT
city : Las Vegas
title : CTO
samAccountName : DonJ
Name : DonJ
Department : IT

login : Gregs
dept : Custodial
city : Denver
title : Janitor
samAccountName : Gregs
Name : Gregs
Department : Custodial

login : JeffM
dept : IT
city : Syracuse
title : Network Engineer
samAccountName : JeffM
Name : JeffM
Department : IT
```

---

<div class="post-metadata">

**Author:** ![ralphmwr](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ralphmwr/32/1064_2.png) [@ralphmwr](https://forums.powershell.org/u/ralphmwr)\
**Post date:** [January 19, 2021, 3:26am UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496/2 "2021-01-19T03:26:01Z")

</div>

The dot (.) in ALL your examples is technically called the “property dereference operator”. See Get-Help About\_Operators. I have searched the documentation and can’t find any reference to a “fallback Dot Operator”. What do you mean by this term?

The $\_ is technically the same as $PSItem. $PSItem is an automatic variable containing the current pipeline object. See Get-Help About\_Automatic\_Variables. In your foreach examples regardless if it is the pipeline to the foreach-object loop or the foreach method of an array object, the $PSItem or $\_ will always represent the current object in the iteration.

As for as combining the two concepts ($PSItem or $\_ and the property dereference operator), the dot operator is simply used to call a property or method of the current pipeline object. Hopefully this helps

---

<div class="post-metadata">

**Author:** ![faris](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/faris/32/18_2.png) [@faris](https://forums.powershell.org/u/faris)\
**Post date:** [January 19, 2021, 7:48am UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496/3 "2021-01-19T07:48:17Z")

</div>

Hi,

First, you can read more about it here [ForEach-Object (Microsoft.PowerShell.Core) - PowerShell | Microsoft Docs](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.1)

Let’s agree about the $ which represents a variable. But when it comes to a pipeline where there is a stream of data passed through the pipeline, each item in this pipeline is considered as a variable and it’s referred to as **$\_** which means an item from the pipeline _which may include an array or whatever_.

In order to reach for these item properties, a **Dot** is used, just like a regular PowerShell the **Dot** is a call for a method or property related to the item

Let’s have some example

Regular variable

```
$Mylist=Get-Process notepad #Now the Mylist Variable will hold all the information related to the Notepad process
```

&nbsp;

Let’s try now to pass this information to Write-host and add a basic format color Green

```
($Mylist).foreach{Write-Host $_ -ForegroundColor green}
```

In the example above $Mylist hold the information of Notepad process and its passed to a Foreach Loop. As you can read the usage of the $\_ represent a single item from the $MyList variable

The output of the above line is Notepad formated in the green color.

Dot Format

Now let think that what we need is not the Object itself _NOTEPAD Process_ but a property of the object, for example, ProcessID, By adding a Dot to $\_ we will be able to tell Powershell that we need property from the pipeline item named ID

```
($Mylist).foreach{Write-Host $_.ID -ForegroundColor green}
```

The $\_ is referring to the object that reaches through the Pipeline, and the DOT after $\_ refer to the property of the item

ITEM Property

You can get more information about the item property by adding **| gm** to any object.

I hope I make things a bit simpler.

---

<div class="post-metadata">

**Author:** ![stephenray](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@stephenray](https://forums.powershell.org/u/stephenray)\
**Post date:** [January 19, 2021, 2:27pm UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496/4 "2021-01-19T14:27:50Z")

</div>

MikeR, Thank you for your reply. I got Dot Operator and FallBack Dot Operator from a Book: Windows Powershell In Action, Third Edition, Bruce Payette & Richard Siddaway, P. 132 and Page 134

[2 PowerShell Features I was Surprised to Love - PowerShell Station](https://powershellstation.com/2017/05/09/2-powershell-features-surprised-love/)

So the dot is used with the Pipeline, you say. I will go study your reference, Get-Help About\_Operators. this but it will take some time before I get back to you.

&nbsp;

Faris, Thank you for your reply, Yes, indeed, I will go study what you say: [https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.1](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.1)

I am liking your examples, You said: “…the **Dot** is a call for a method or property related to the item.” I will go study this. I will have to run some examples in PowerShell and examine everything and learn it.

I will be most interested to read the rules about this.

I will get back after I have studied, but it will take some time, I am working about 12 hours every day.

Thanks, guys.

```

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/punctuation-help-and-dot-operator-and-fallback-dot-operator/15496/5 "2024-05-16T20:28:00Z")

</div>


