我们正在尝试通过 Powershell 连接到远程服务器并使用 ActiveDirectory 模块。尝试在本地执行此操作时,一切似乎都很好。
PS C:\Users\bar> Import-Module ActiveDirectory
PS C:\Users\bar> Get-ADUser 'baz'
DistinguishedName : CN=Foo Baz,OU=baz.myhost.com,OU=FooMachine,DC=foo,DC=blah,DC=loc
Enabled : True
GivenName : Baz
Name : Foo Baz
ObjectClass : user
ObjectGUID : <some guid>
SamAccountName : baz
SID : <more info here>
Surname : Baz
UserPrincipalName : baz@foo
Run Code Online (Sandbox Code Playgroud)
当我们远程做同样的事情时,我们就没有那么幸运了。
C:\> Enter-PSSession -ComputerName 172.1.2.3 -Credential foo\bar
[172.1.2.3]: PS C:\Users\bar\Documents> Import-Module ActiveDirectory
WARNING: Error initializing default drive: 'Unable to contact the server. This
may be because this server does not exist, it …
Run Code Online (Sandbox Code Playgroud)