如何查找PowerShell静态类和方法?

jra*_*ara 2 .net c# powershell powershell-2.0

如何找到PowerShell 2.0中可用的静态类和方法?

dri*_*iis 7

您可以使用PowerShell中的任何.NET类型及其静态方法.要枚举当前加载到AppDomain中的所有内容,您可以执行以下操作:

 [AppDomain]::CurrentDomain.GetAssemblies() | foreach { $_.GetTypes() } | foreach { $_.GetMethods() } | where { $_.IsStatic } | select DeclaringType, Name | format-table
Run Code Online (Sandbox Code Playgroud)

请记住,您不仅限于静态方法,还可以使用new-object和调用实例方法来实例化类型.您可以get-member在实例上使用以获取类型的方法.

此外,如果要列出可用的CmdLets,只需调用:

Get-Command
Run Code Online (Sandbox Code Playgroud)