环境配置说明
- 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 Core。
欢迎关注公众号:悟为生心