Powershell find and store the file name
Some options for your specific use case
Get-Item myf* | Select-Object -ExpandProperty Name
(Get-Item myf* | Select-Object Name).Name
A bit of backgroud
The Select-Object Name
still returns an object, not just a string.
You can verify yourself by adding | Get-Member
TypeName: Selected.System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Name NoteProperty string Name=myfile