Example code:
<p class=“x-hidden-focus”>Get-WmiObject -Class win32_OperatingSystem -ComputerName webr201 | </p>
<p class=“x-hidden-focus”>select @{N=‘ComputerName’; E={$.PSComputerName}}, </p>
<p class=“x-hidden-focus”>@{N=‘OS’; E={$ .caption}}, </p>
<p class=“x-hidden-focus”>@{N=‘SP’; E={$_.ServicePackMajorVersion}} </p>
Question:
What is @ an what are N and E ?
Really appreciate your answer.
In other words - I´m new with Powershell
`@{}` indicates a creation of a hashtable.
N = Name, E = Expression.
Using aliases in PowerShell is not recommended for the reasons you just asked in your question. New PowerShell users may not know the alias or abbreviation of a command.
pwshliquori
js2010
April 10, 2019, 8:43am
4
PS C:\users\me> $a = @{N='ComputerName'; E={$_.PSComputerName}}
PS C:\users\me> $a
Name Value
---- -----
N ComputerName
E $_.PSComputerName
PS C:\users\me> $a.n
ComputerName
PS C:\users\me> $a.gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Hashtable System.Object
PS C:\users\me> Get-WmiObject win32_OperatingSystem | select $a
ComputerName
------------
MYCOMPUTER
PS C:\users\me> $b = {$_.PSComputerName}
PS C:\users\me> $b.gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True ScriptBlock System.Object