【发布时间】:2013-04-28 03:04:54
【问题描述】:
我可能没有这个问题的准确标题,但我只是在学习 powershell,我现在很困惑。我有以下情况加上我想知道如何查看.NET函数(在这个问题的末尾)例如,我有:
System.DirectoryServices.DirectoryEntry
我将它设置为一个变量,如下所示:
$test = new-object System.DirectoryServices.DirectoryEntry
如果我想获得这方面的方法,我会这样做:
$test | gm
这会返回许多不同的名称和成员类型,但我只想要成员类型 method 但如果我这样做:
$test | gm -membertype method
我没有得到任何结果...但是,如果我这样做了
$test.get_children()
它将列出可分辨的名称和路径...所以我的问题是,如果这是一种方法,为什么现在在我调用 GM -membertype method 时会显示它??
如果我这样做了
,$test.get_children() | gm
我有各种不同的方法,但如果我这样做了
$test.get_children() | gm
我只收到properties 为什么不显示方法?我还应该注意我无法为,$test.get_childre() | gm 使用任何 Membertype 方法
这对我来说没有多大意义。有人可以解释一下,以及如何确定我可以用特定的 .NET 函数做什么。另一个这样的例子是:
$domain = [System.DirecotryServices.ActiveDirectory.Domain]
我该如何浏览这个?所以我想我应该做 System. -> 看看有什么可用的,然后选择 DirectoryServices -> 看看有什么可用的
【问题讨论】:
-
[system.directoryservices.activedirectory.domain] |通用
-
我猜你看到的另一件事是由于适配器 ([adsi]) powershell 具有该类。如果你做 $test.psbase | gm 你会看到你正在寻找的结果。