在Powershell中获取成员并在.Net中导航

在Powershell中获取成员并在.Net中导航,powershell,powershell-2.0,Powershell,Powershell 2.0,对于这个问题,我可能没有一个准确的标题,但我只是在学习powershell,我现在非常困惑。我有以下情况,另外我想知道如何查看.NET函数(在本问题末尾),例如,我有: System.DirectoryServices.DirectoryEntry 我将其设置为一个变量,如下所示: $test = new-object System.DirectoryServices.DirectoryEntry 如果我想获得这方面的方法,我会: $test | gm 这将返回许多不同的名称和成员类型,但

对于这个问题,我可能没有一个准确的标题,但我只是在学习powershell,我现在非常困惑。我有以下情况,另外我想知道如何查看.NET函数(在本问题末尾),例如,我有:

System.DirectoryServices.DirectoryEntry
我将其设置为一个变量,如下所示:

$test = new-object System.DirectoryServices.DirectoryEntry
如果我想获得这方面的方法,我会:

$test | gm
这将返回许多不同的名称和成员类型,但我只需要membertype
method
,但如果我需要:

$test | gm -membertype method
我没有得到任何结果…但是,如果我得到了

$test.get_children()
它将列出可分辨名称和路径…所以我的问题是,如果这是一个方法,为什么现在在我调用
GM-membertype方法时它会出现?

还有,如果我

,$test.get_children() | gm
我有各种不同的方法,但如果我有

$test.get_children() | gm
我只收到
属性
为什么它不显示方法?我还应该注意,我无法使用
,$test.get_childre()| gm

这对我来说没什么意义。有人能解释一下这一点,以及如何确定我可以用特定的.NET函数做什么吗。另一个这样的例子是:

$domain = [System.DirecotryServices.ActiveDirectory.Domain]

我如何浏览此页面?所以我想我应该做这个系统。->查看哪些可用,然后选择DirectoryServices->并查看哪些可用

我可以使用以下方法列出这些方法:

$test = new-object System.DirectoryServices.DirectoryEntry    
$test.psbase | get-member -force -Type Method

如果不指定-Force参数,您将无法查看在该对象上查找的所有方法。

您还可以使用此方法获取方法和所有其他隐藏成员:

$test | gm -MemberType method -View All -Force
有关详细信息,请在控制台中键入:

 help gm -param view

[system.directoryservices.activedirectory.domain]| gman我想您看到的另一件事是由于powershell为该类提供了适配器([adsi])。如果您执行$test.psbase | gm,您将看到您正在寻找的结果。