Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Active directory命令在powershell中不工作_Powershell_Amazon Web Services_Amazon Ec2_Active Directory - Fatal编程技术网

Active directory命令在powershell中不工作

Active directory命令在powershell中不工作,powershell,amazon-web-services,amazon-ec2,active-directory,Powershell,Amazon Web Services,Amazon Ec2,Active Directory,我有一个脚本,它将一台机器添加到域中,将其移动到特定的组织单元,并将机器添加到Active Directory组 添加到域和移动到OU正在工作但机器未添加到AD组中。 我正在尝试的命令: $name=gc env:computername $secpasswd = ConvertTo-SecureString "Passwd" -AsPlainText -Force $mycreds = New-Object System.Management.Automation.PSCredential("

我有一个脚本,它将一台机器添加到域中,将其移动到特定的组织单元,并将机器添加到Active Directory组

添加到域和移动到OU正在工作但机器未添加到AD组中。

我正在尝试的命令:

$name=gc env:computername
$secpasswd = ConvertTo-SecureString "Passwd" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential("abc\user",$secpasswd)
Add-ADGroupMember -id GroupName -Members "CN=$name,OU=POC,DN=abc,DN=com" -Credential $mycreds
我已经做过的事情:

$name=gc env:computername
$secpasswd = ConvertTo-SecureString "Passwd" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential("abc\user",$secpasswd)
Add-ADGroupMember -id GroupName -Members "CN=$name,OU=POC,DN=abc,DN=com" -Credential $mycreds
-在计算机中安装了Active Directory域服务角色

-启动了active directory web服务

-然后导入active directory模块

错误

Add-ADGroupMember : Unable to contact the server. This may be because the server does not exist, it is currently down, or it does not have Active Directory Web Services running.
At line1: char:1
+Add-ADGroupMember -id GroupName -Members "CN=$name,OU=POC,DN=abc,DN=com"

 +CategoryInfo: ResourceUnavailable:<GroupName:ADGroup> [Add-ADGroupMember],ADServerDownException

 +FullyQualifiedErrorId :ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
添加ADGroupMember:无法与服务器联系。这可能是因为服务器不存在、当前已关闭或没有运行Active Directory Web服务。
在第1行:字符:1
+添加ADGroupMember-id GroupName-Members“CN=$name,OU=POC,DN=abc,DN=com”
+CategoryInfo:ResourceUnavailable:[添加ADGroupMember],ADServerDownException
+FullyQualifiedErrorId:ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
我还尝试执行其他AD命令,如Get-ADGroupMember等,所有Active Directory命令在powershell中都会出现相同的错误

我错过什么了吗?在这个问题上,我陷入了困境。请导游


提前谢谢

让我们先尽量减少复杂性。您正在脚本中移动计算机对象,因此不要尝试指定计算机的FQDN,而是尝试使用SAMAccountName。这样,如果您在移动计算机时遇到问题,我们可以消除一个可能的复杂性

除此之外,请尝试在添加ADGroupMember步骤中指定一个广告服务器。我的想法是,您正在执行域加入,然后执行其他操作,那么,您的系统还没有登录到新域,因此可能很难找到域控制器

要重复故障排除步骤,我将尝试:

  • 使用要添加到组的计算机的SamAccountName(而不是计算机的FQDN)尝试现有进程。这可能是导致问题的原因
  • 如果不起作用,请使用
    -Server ServerName
    参数指定要联系的AD服务器以添加组成员资格

  • 所有这些动作都在同一个脚本中吗?系统重新启动后,
    Add ADGroupMember
    是否工作?在此之前它不是正式的域成员。@Matt:no Add ADgroupMember即使在重新启动后也不工作。。即使在将计算机正确添加到域中,它也会失败。@RedOne:hey现在active directory模块在第一次运行时没有被导入。。它显示出错误。。当我在错误后再次导入它时,它正在被导入。。我不明白为什么它会在第二次运行时执行?