In Powershell, I'm calling [io.path]::GetExtension(..) as so:
...| Select-Object {[io.path]::GetExtension($_)}
and I get the following output:
[io.path]::GetExtension($_)
---------------------------
.dll
.dll
.dll
.dll
.dll
.dll
.dll
.dll
.dll
.dll
(Note some inputs lack an extension, so their output are empty)
And piping that to "Get-Member" produces:
TypeName: Selected.System.String
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
[io.path]::GetExtension($_) NoteProperty System.String [io.path]::GetExtension($_)=
However I want System.String, and not a Selected.System.String, as I want to Group-Object, and I (apparently) cannot group Selected.System.String as it doesn't implement IComparable.
Calling ".ToString()" doesn't throw an error, but it doesn't convert it to a string.
How can I produce a string, or convert the output to a string?
Select-Object {[io.path]::GetExtension($_)}toSelect-Object -ExpandProperty Extension.IO.FileInfoinput objects (not unreasonable, since you did not specify what you were piping). In this case you would replace yourSelect-ObjectwithForEach-Object {[IO.Path]::GetExtension($_) }.