PowerShell解析.NET选项卡完成方法和属性

PowerShell解析.NET选项卡完成方法和属性,.net,powershell,console,.net,Powershell,Console,我可以在PowerShell控制台上键入[System.,然后使用Tab completion,但是否有办法在输入后解析所有可能的值。?我知道我可以使用Ctrl+Space显示所有值,但我可以通过编程方式返回所有值吗 类似地,我可以键入[System.IO.Path]::制表符补全将显示诸如GetFileName WithoutExtension之类的属性,我也可以使用Ctrl+Space来显示值,但对于这一点,是否有方法以编程方式返回所有可能的.NET方法和属性?CRTL+Spacebar也可

我可以在PowerShell控制台上键入[System.,然后使用Tab completion,但是否有办法在输入后解析所有可能的值。?我知道我可以使用Ctrl+Space显示所有值,但我可以通过编程方式返回所有值吗

类似地,我可以键入[System.IO.Path]::制表符补全将显示诸如GetFileName WithoutExtension之类的属性,我也可以使用Ctrl+Space来显示值,但对于这一点,是否有方法以编程方式返回所有可能的.NET方法和属性?

CRTL+Spacebar也可以与[System.well]一起使用

如图所示

[System. # then CTRL+Spacebar

Loading personal and system profiles took 3487ms.
 [System.
Display all 241 possibilities? (y or n) _ 

# Select 'y'

 [System.
AccessViolationException               EventHandler                           OutOfMemoryException
Action<>                               Exception                              OverflowException
ActivationContext                      ExecutionEngineException               ParamArrayAttribute
Activator                              FieldAccessException                   PlatformID
AdjustmentRule                         FileStyleUriParser                     PlatformNotSupportedException...
如果您的意思是,给您一个弹出列表供您选择,就像ISE或VSCode或Visual Studio那样,那么就不会了,这就是为什么ISE/VSCode/Visual Studio和其他PowerShell编辑器存在的原因,以帮助那些希望在前进之前看到可用优点的人

至于

有没有办法以编程方式返回所有可能的.NET方法 还有财产

这只是我在我的个人资料/我的个人模块中收集的内容的一部分,用于查找您似乎也在寻找的用例

### Query Powershell Data Types
[AppDomain]::CurrentDomain.GetAssemblies() | 
Foreach-Object { $_.GetExportedTypes() }

# Or 

[psobject].Assembly.GetType(“System.Management.Automation.TypeAccelerators”)::get

# Or

    [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::Get.GetEnumerator() | 
Sort-Object -Property Key


# Finding the properties of a .NET class
[System.Environment].DeclaredProperties.Name


# Looping through static properties.
$obj = [environment]
$obj | get-member -Static -MemberType property | 
foreach name | 
foreach { "$_ = $($obj::$_)" }


<#
 Get any .NET types and their static methods from PowerShell. 
 Enumerate all that are currently loaded into your AppDomain.
#>  
[AppDomain]::CurrentDomain.GetAssemblies() | 
foreach { $_.GetTypes() } | 
foreach { $_.GetMethods() } | 
where { $_.IsStatic } | 
select DeclaringType, Name | 
Out-GridView -PassThru -Title '.NET types and their static methods'

# Instantiate the types using new-object and call instance methods. 
# You can use get-member on an instance to get the methods on a type.

$Object = [psobject].Assembly.GetType(“System.Management.Automation.TypeAccelerators”)::get
$Object | Get-Member
$Object | Get-Member -Static
$Object.GetType()
$Object.GetEnumerator()


# Show Public methods
[System.Management.Automation.ModuleIntrinsics]::GetModulePath

# Show Private methods
[System.Management.Automation.ModuleIntrinsics] | 
Get-Member -Static

### .Net API Browsers
<#
https://docs.microsoft.com/en-us/dotnet/api/?view=netframework-4.8
https://docs.microsoft.com/en-us/dotnet/framework/additional-apis/index
http://pinvoke.net
#>
在我的profile/ModuleLibrary中,我根据需要直接或间接地在代码中调用这些和更多的东西