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