EsO*_*OsO 51 powershell active-directory powershell-3.0
我遇到这个命令有问题:
gc .\domains.txt | Get-ADDomain
Run Code Online (Sandbox Code Playgroud)
顾名思义,domains.txt包含要查询的Active Directory列表(所有域都在同一个林中).
If I run it on my Windows 8 machine everything works fine and I get the expected results, instead on a Windows 2008 R2 SP1 member server (not a DC) with WMF 3.0 I get result only from the first domain in the list and for the others:
Get-ADDomain : A referral was returned from the server
Run Code Online (Sandbox Code Playgroud)
If I query a domain in the list with:
Get-ADDomain <Domain name here>
Run Code Online (Sandbox Code Playgroud)
it works fine.
Microsoft Windows 8 Enterprise (6.2.9200) x64
PS D:\Tools\Powershell> $PSVersionTable
Name Value
---- -----
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18010
BuildVersion 6.2.9200.16384
PSCompatibleVersions {1.0, 2.0, 3.0}
PSRemotingProtocolVersion 2.2
Run Code Online (Sandbox Code Playgroud)
Microsoft Windows Server 2008 R2 Standard SP1 (6.1.7601) x64
PS C:\Tools\Powershell> $PSVersionTable
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.269
PSRemotingProtocolVersion 2.2
Run Code Online (Sandbox Code Playgroud)
If i run on the server:
gc .\domains.txt | %{ Get-ADDomain $_ }
Run Code Online (Sandbox Code Playgroud)
it runs fine
trace-command -Name ParameterBinding { "DOMAIN_1","DOMAIN_2" | Get-ADDomain } -PSHost
Run Code Online (Sandbox Code Playgroud)
Server: http://pastebin.com/sRVJHaCU
Workstation: http://pastebin.com/kj3JV6nV
Thanks in advance
小智 0
我只是尝试运行 cmdlet 'gc .\text.txt | 从我拥有的虚拟 Server 2008 R2 框中获取 ADDomain。我以以下格式构建了一个文本文件:
Domain1
Domain2
Domain3
Run Code Online (Sandbox Code Playgroud)
需要确定的一件事是每个域在文本文件中都位于其自己的行上。我可以理解为什么当您将 STDOUT 通过管道传输到以下位置时,一种语法有效:
%{ Get-ADDomain $_}
Run Code Online (Sandbox Code Playgroud)
因为您正在循环遍历文本文件中包含的所有信息,并且一次只能让 cmdlet 对单个值起作用。不幸的是,我的 Win 8 桌面上没有 RSAT 软件包,因此我无法从桌面进行测试。希望这会有所帮助。
归档时间: |
|
查看次数: |
1629 次 |
最近记录: |