PowerShell Select-Object Property和ExpandProperty的差别#yyds干货盘点#

网友投稿 896 2022-09-17

PowerShell Select-Object Property和ExpandProperty的差别#yyds干货盘点#

PowerShell Select-Object Property和ExpandProperty的差别#yyds干货盘点#

环境配置说明

Windows 21H1 PSVersion 5.1.19041.1320

示例

PS C:\Users\admin> Get-Alias | Select-Object -Property ModuleName | Get-Member TypeName:Selected.System.Management.Automation.AliasInfo Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() ModuleName NoteProperty string ModuleName=

PS C:\Users\admin> Get-Alias | Select-Object -ExpandProperty ModuleName | Get-Member TypeName:System.String Name MemberType Definition ---- ---------- ---------- Clone Method System.Object Clone(), System.Object ICloneable.Clone() CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IC... Contains Method bool Contains(string value) CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex,... EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.String... Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals... GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator ... GetHashCode Method int GetHashCode() GetType Method type GetType() GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode() .....

-ExpandProperty ModuleName 的返回类型是 System.String ,更适合作参数,适用范围较广

PS C:\Users\admin> Get-Alias | Select-Object -Property ModuleName | Select-Object -First 10 ModuleName ---------- Microsoft.PowerShell.Utility

PS C:\Users\admin> Get-Alias | Select-Object -ExpandProperty ModuleName | Select-Object -First 10 Microsoft.PowerShell.Utility

学习资料

PowerShell 版本 + 工具 PowerShell/PowerShell 51CTO社区

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Flask开发技巧之异常处理(flask 漏洞)
下一篇:PowerShell Select-Object 选择要显示的列#yyds干货盘点#
相关文章

 发表评论

暂时没有评论,来抢沙发吧~