jeudi 5 février 2015

Active directory commands not working in powershell

I have a script which adds a machine to domain, move it to particular Organization Unit and add the machine to Active Directory Group.


The adding to domain and moving to OU is working. But the machine is not getting added in AD Group.


Command I am trying:



$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


Things which I have already done:


-installed the Active Directory Domain Services role in the machine


-started the active directory web services


-then imported the active directory module


Error:



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


I also tried executing other AD commands like Get-ADGroupMember etc, all the Active Directory commands are giving the same error in powershell.


Am i missing something? stuck at this issue. Please guide.


Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire