PowerShell question

What does this variable do in PowerShell?   @( )    As well as this one?  @{n=

Thank you!!
Anthony K O365Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
@() is for arrays, and @(n=xxx) is to get the array item xxx from there

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The "@()" is just the definition of an array:
$SomeIntegerArray = @(1, 2, 3, 4)

Open in new window

In general, "@{}" defines a hash table, which is basically an array that doesn't use a numeric index but Key-Value pairs.
$SomeHashTable = @{foo=1; bar=2}

Open in new window

Windows PowerShell Tip of the Week > Working with Hash Tables

In this case, the "@{n=" looks like the definition of a hash table used for a "Calculated Property"; with Select-Object, you can define additional properties on the fly.
The example taken from the link below will get the items in a folder and generate a new property "Kbytes" to have the file size available in KB (by default, the size is returned in bytes).
Get-ChildItem C:\Test | Select-Object Name, CreationTime,  @{Name="Kbytes";Expression={$_.Length / 1Kb}}

Open in new window

The keys "Name" (the name of the new property) and "Expression" (the expression used to generate the value of the new property) of the hash table can be shortened to "n" and "e".
Get-ChildItem C:\Test | Select-Object Name, CreationTime,  @{n="Kbytes";e={$_.Length / 1Kb}}

Open in new window

Windows PowerShell Tip of the Week > Using Calculated Properties
Anthony K O365Author Commented:
Excellent! This helps as I'm still ramping up on PowerShell.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.