Custom Column incrementing count

Just want custom column that shows current item number.

$CultureInfo = [cultureinfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures)

$CultureInfo|select -Property Name, DisplayName, @{Label=‘Number’;Expression={[int]$ctr++ ;Write-Host $ctr}} not working.

done manually but like this.

Name DisplayName Number


   Invariant Language (Invariant Country)      0

aa Afar 1
aa-DJ Afar (Djibouti) 2
aa-ER Afar (Eritrea) 3
aa-ET Afar (Ethiopia) 4
af Afrikaans 5
af-NA Afrikaans (Namibia) 6
af-ZA Afrikaans (South Africa) 7
agq Aghem 8
agq-CM Aghem (Cameroon) 9

Found it myself, here it is

$CultureInfo|select -Property Name, DisplayName, @{Label=‘Number’;Expression={[int]$script:ctr++}}

Name DisplayName Number


           Invariant Language (Invariant Country)                0

aa Afar 1
aa-DJ Afar (Djibouti) 2
aa-ER Afar (Eritrea) 3
aa-ET Afar (Ethiopia) 4
af Afrikaans 5
af-NA Afrikaans (Namibia) 6
af-ZA Afrikaans (South Africa) 7
agq Aghem 8
agq-CM Aghem (Cameroon) 9

David,
Welcome to the forum. :wave:t4:

Grerat you’ve found a solution yourself. :+1:t4: And thanks for share it here. :wink:

But - next time you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Don’t forget to zero out variable between calls

$script:ctr = 0

Is there anyway to edit a post?

Usually there is. It is the “pen” symbol. :wink:

The complete code.
:vulcan_salute:

$CultureInfo = [cultureinfo]::GetCultures([System.Globalization.CultureTypes]::AllCultures)
[int]$Script:ctr = 0;$CultureInfo|select -Property Name, DisplayName, @{Label='Index';Expression={[int]$Script:ctr++}}

to access a certain index from above code.

$CultureInfo[49].DateTimeFormat