Home > Software engineering >  How to pick the first element of a list in powershell keeping auto-complete?
How to pick the first element of a list in powershell keeping auto-complete?

Time:12-22

This is the command I am invoking:

Get-ChildItem | where -Property name -like *asda* | select -first 1 | $_.Name

Obviously this call at the end doesn't work because the $_ only works for iterable loops. But I want to pick that element of the list and turn it into a object where I can call auto complete (ctrl space).

How can I achieve that in Powershell?

CodePudding user response:

Do you try ?

(Get-ChildItem | where -Property name -like *asda* | select -first 1).Name
  • Related