2013-05-03 20 views
4

我可能没有一个准确的标题这个问题,但我只是在学习PowerShell,我现在很困惑。我有以下的情况再加上我想知道如何通过.NET函数看(在这个问题结束)例如,我有:获取成员和在Powershell中通过.Net导航

System.DirectoryServices.DirectoryEntry 

我设置为一个变量,像这样:

$test = new-object System.DirectoryServices.DirectoryEntry 

如果我想这样做的方法,我做的:

这将返回许多不同的名称和membertypes但我只想membertype method,但如果我这样做:

$test | gm -membertype method 

我没有得到任何结果。不过,如果我做

$test.get_children() 

它会列出不同的名称和路径...... 所以我的问题是为什么,如果这是一个方法,现在显示出来,当我拨打GM -membertype method

而且,如果我做

,$test.get_children() | gm 

我获得各种不同的方法,但如果我这样做

$test.get_children() | gm 

我什么也得不到,但properties为何不显示的方法呢?我还应该注意到我无法使用任何Membertype方法,$test.get_childre() | gm

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

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

我如何可以导航通过这个?所以我想象我应该做System。 - >看看什么是可用的,并挑选的DirectoryServices - >,看看是可用的编缉从那里

+0

[system.directoryservices.activedirectory.domain] | gm – 2013-05-03 17:26:25

+1

我想你看到的另一件事是由于适配器([adsi])powershell对该类的影响。如果你做$ test.psbase |你会看到你正在寻找的结果。 – 2013-05-03 17:27:41

回答

0

我可以使用下面的方法来列出方法:

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

不指定强制参数,您将无法看到您在该对象上寻找的所有方法。

0

您也可以使用这种方法的方法和所有其他隐藏成员:

$test | gm -MemberType method -View All -Force 

键入此为您控制台的更多信息:

help gm -param view