沉舟侧畔千帆进,病树前头万木春。这篇文章主要讲述PowerShell Get-Member 查看对象的成员列表相关的知识,希望能为你提供帮助。
环境配置说明
- Windows 21H1
- PSVersion 5.1.19041.1320
示例
PS C:\\Users\\admin>
Get-Alias | Get-MemberTypeName:System.Management.Automation.AliasInfoNameMemberTypeDefinition
------------------------
EqualsMethodbool Equals(System.Object obj)
GetHashCodeMethodint GetHashCode()
GetTypeMethodtype GetType()
ResolveParameterMethodSystem.Management.Automation.ParameterMet...
ToStringMethodstring ToString()
CommandTypePropertySystem.Management.Automation.CommandTypes...
DefinitionPropertystring Definition {get;
}
DescriptionPropertystring Description {get;
set;
}
ModulePropertypsmoduleinfo Module {get;
}
ModuleNamePropertystring ModuleName {get;
}
NamePropertystring Name {get;
}
OptionsPropertySystem.Management.Automation.ScopedItemOp...
OutputTypePropertySystem.Collections.ObjectModel.ReadOnlyCo...
ParametersPropertySystem.Collections.Generic.Dictionary[str...
ParameterSetsPropertySystem.Collections.ObjectModel.ReadOnlyCo...
ReferencedCommandPropertySystem.Management.Automation.CommandInfo ...
RemotingCapabilityPropertySystem.Management.Automation.RemotingCapa...
ResolvedCommandPropertySystem.Management.Automation.CommandInfo ...
SourcePropertystring Source {get;
}
VersionPropertyversion Version {get;
}
VisibilityPropertySystem.Management.Automation.SessionState...
DisplayNameScriptProperty System.Object DisplayName {get=if ($this....
HelpUriScriptProperty System.Object HelpUri {get=$oldProgressPr...
ResolvedCommandName ScriptProperty System.Object ResolvedCommandName {get=$t...
Get-Alias对象的属性
CommandTypePropertySystem.Management.Automation.CommandTypes...
DefinitionPropertystring Definition {get;
}
DescriptionPropertystring Description {get;
set;
}
ModulePropertypsmoduleinfo Module {get;
}
ModuleNamePropertystring ModuleName {get;
}
NamePropertystring Name {get;
}
OptionsPropertySystem.Management.Automation.ScopedItemOp...
OutputTypePropertySystem.Collections.ObjectModel.ReadOnlyCo...
ParametersPropertySystem.Collections.Generic.Dictionary[str...
ParameterSetsPropertySystem.Collections.ObjectModel.ReadOnlyCo...
ReferencedCommandPropertySystem.Management.Automation.CommandInfo ...
RemotingCapabilityPropertySystem.Management.Automation.RemotingCapa...
ResolvedCommandPropertySystem.Management.Automation.CommandInfo ...
SourcePropertystring Source {get;
}
VersionPropertyversion Version {get;
}
VisibilityPropertySystem.Management.Automation.SessionState...
DisplayNameScriptProperty System.Object DisplayName {get=if ($this....
HelpUriScriptProperty System.Object HelpUri {get=$oldProgressPr...
ResolvedCommandName ScriptProperty System.Object ResolvedCommandName {get=$t...
通过将Get-Alias的结果导出成csv文件的方法,可以查看到列名和Property是相互对应的。在powershell中,存在多种类型的Property,比如ScriptProperty等。
PS C:\\Users\\admin>
Get-Alias | Export-Csv alias.csv
#TYPE System.Management.Automation.AliasInfo
"HelpUri","ResolvedCommandName","DisplayName","ReferencedCommand","ResolvedCommand","Definition","Options","Description","OutputType","Name","CommandType","Source","Version","Visibility","ModuleName","Module","RemotingCapability","Parameters","ParameterSets"
Get-Alias对象的方法
EqualsMethodbool Equals(System.Object obj)
GetHashCodeMethodint GetHashCode()
GetTypeMethodtype GetType()
ResolveParameterMethodSystem.Management.Automation.ParameterMet...
ToStringMethodstring ToString()
学习资料
- PowerShell 版本 + 工具
- PowerShell/PowerShell
- 51CTO社区
【PowerShell Get-Member 查看对象的成员列表】感恩曾经帮助过 师万物 的人。
学有余力的话,可以了解具有开源、跨平台特性的Powershell Core。
欢迎关注公众号:悟为生心
推荐阅读
- PowerShell Get-Module 查看PSModulePath路径中的模块
- PowerShell Select-Object Property和ExpandProperty的差别
- PowerShell Sort-Object 按照列的内容进行升降序排列
- k8s中的容器优雅关闭,何为“优雅”
- PowerShell Get-NetAdapter 查看网络适配器的参数
- PowerShell Where-Object 筛选出包含指定内容的行
- #yyds干货盘点#iptables防火墙
- 01 局域网yum 源仓库的安装
- PowerShell Get-PSRepository 查看存储库信息