Forum Discussion
mbuddd
Sep 21, 2021Copper Contributor
Creating an on premise Active Directory Security group
Hello, This is only for on premise Active Directory. I would like to do the following: Get user credentials Identify the domain where the security is to be created Get the name of the user...
mbuddd
Sep 21, 2021Copper Contributor
How does one connect to domain with domain namespace? Could you please provide an example with powershell code?
I use the command:
$credentials = Get-Credential
PS C:\temp> $credentials
UserName Password
-------- --------
my-lab.net\mbtest System.Security.SecureString
PS C:\temp> New-ADGroup -Name $ADSecurityGroup -SamAccountName $ADSecurityGroup -GroupCategory Security -GroupScope Global -DisplayName $ADSecurityGroup -Path $orgUnit -Credential $Credentials
Error:
New-ADGroup : Access is denied
At line:1 char:1
+ New-ADGroup -Name $ADSecurityGroup -SamAccountName $ADSecurityGroup - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (CN=etest,OU=CRA...=cldsvcs,DC=net:String) [New-ADGroup], UnauthorizedAccessException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.UnauthorizedAccessException,Microsoft.ActiveDirectory.Management.Commands.NewADGroup
I use the command:
$credentials = Get-Credential
PS C:\temp> $credentials
UserName Password
-------- --------
my-lab.net\mbtest System.Security.SecureString
PS C:\temp> New-ADGroup -Name $ADSecurityGroup -SamAccountName $ADSecurityGroup -GroupCategory Security -GroupScope Global -DisplayName $ADSecurityGroup -Path $orgUnit -Credential $Credentials
Error:
New-ADGroup : Access is denied
At line:1 char:1
+ New-ADGroup -Name $ADSecurityGroup -SamAccountName $ADSecurityGroup - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (CN=etest,OU=CRA...=cldsvcs,DC=net:String) [New-ADGroup], UnauthorizedAccessException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.UnauthorizedAccessException,Microsoft.ActiveDirectory.Management.Commands.NewADGroup
farismalaeb
Sep 22, 2021Steel Contributor
Multiple factor can be the cause, but try this
New-ADGroup -Name "TestGroup" -SamAccountName "TestGroup" -GroupCategory Security -GroupScope Global -
DisplayName "TestGroup" -Credential $cred -Server 10.6.10.10 -AuthType Negotiate