Jump to content
Microsoft Windows Bulletin Board

Powershell, setting adminrights(SOLVED)


Recommended Posts

Posted

Hello,

 

What im trying to do is delegating control (admin rights) to specific users in a security group so that they are administrators for a OU.

 

However i get the error message:

 

You cannot call a method on a null-valued expression.

 

At line:0 char:1

 

+ $OU.psbase.ObjectSecurity.AddAccessRule($ACE)

 

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

+ CategoryInfo : InvalidOperation: (:) [], RuntimeException

 

+FUllyQualifiedErrorId : InvokeMethodNull

 

Below is the complete script:

 

$OU = [ADSI]("LDAP://OU=Teknik,OU=Melldala,DC=lab,DC=nu")

$Group = Get-ADGroup ("Teknik")

$Sid = [system.Security.Principal.SecurityIdentifier] $Group.SID

$identity = [system.Security.Principal.IdentityReference] $SID

$adRights = [system.DirectoryServices.ActiveDirectoryRights] ("GenericAll")

$type = [system.Security.AccessControl.AccessControlType] ("Allow")

$Inheritencetype = [system.DirectoryServices.ActiveDirectorySecurityInheritance] "All"

$ACE = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $identity,$adrights,$Inheritencetype

$OU.psbase.ObjectSecurity.AddAccessRule($ACE)

$OU.psbase.commitchanges()

 

 

Any Ideas?

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...