简体   繁体   中英

PowerShell returning Length property on SELECT *

I was trying to get all the string properties and methods. And instead of >"1,2,3,4,5,6" | Get-Member just out of curiosity I tried the following command and it gives me the Length property of String object. I thought it will give me error or no output. Any idea why it is doing this? Or How PowerShell interprets SELECT command?

    PS C:>"1,2,3,4,5,6" | SELECT * 

    Length  
    -----------

    11

Length is the only property of System.String the rest of the members are methods. You can see this by doing:

"1,2,3,4,5,6" | Get-Member

Select is an alias for Select-Object . Select-Object -Property * says list all properties and property values of the incoming object.

You can see all the members of System.String here and read up on the Select-Object cmdlet here .

This is easy to do when parsing text. You can use PSCX Get-TypeName to debug type issues from normal PowerShell session (can use breakpoints in ISE window).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM