0

Can someone help me understand what 'n' and 'e' stand for in this command. They don't certainly seems like variables because when I replace them with a and b the command returns no output

Import-Module ActiveDirectory
Get-ADUser username -Properties * -Server mydomain | select -Property name,@{n='Manager';e={(Get-ADUser $_.manager).name}}
js2010
  • 23,033
  • 6
  • 64
  • 66
Yogad
  • 1
  • 1
  • 5
    `n` is short for `Name`; `e` is short for `Expression`. That is how to create a calculated property. Personally I would not use these shortened names because they can quickly lead to misunderstanding code. – Theo Mar 11 '21 at 15:52
  • 'n' and 'e' is a keys of hashtable,and judging by the context, which is also a property with present keys – FletcherF1 Mar 11 '21 at 15:54
  • 3
    here's an article on the idea ... >>> about_Calculated_Properties - PowerShell | Microsoft Docs — https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_calculated_properties?view=powershell-7.1 <<< //// one additional point ... there are several cmdlets that can use calculated props - `Group-Object` is one such. [*grin*] – Lee_Dailey Mar 11 '21 at 15:58
  • Note: The linked post isn't strictly a duplicate, but [its answer](https://stackoverflow.com/a/39861920/45375) explains the format of calculated properties in detail in the context of a `Select-Object` call. – mklement0 Mar 11 '21 at 16:33

0 Answers0