select members from a file object

I know this is a stupid question, but I’ve spent two hours on this. I know I can use the $_ to select the current object in the pipeline, but I don’t know how to select a file object in a given folder and then get it’s members. for example I have a file named foo.txt and want to access it’s extension property.

I can do (ls foo.txt).extension, but was wondering if there’s another, more direct way.

seems you have already found the most direct way :slight_smile:
if you can access the current object in the pipeline with $_ then that represents the file object but you dont need to use $_ for file objects

ls | select-object *
ls | select Name,Extension

this will get all the file objects in the current directory. If you are looking for a specific file then you can use -filter or where-object

ls -filter myfile | select *