Powershell add user to group

前端 未结 2 664
梦毁少年i
梦毁少年i 2021-01-16 04:26

I am trying to read an XML file with user information and based on that information I want to add users to Active Directory groups. I have been looking up the error messages

2条回答
  •  半阙折子戏
    2021-01-16 05:14

    This do what you need:

    $Connection = "LDAP://Server/CN=MyGoup,OU=MyOU,DC=MY,DC=CORP"
    
    $Group = [adsi] $Connection
    
    $User = "LDAP://Server/CN=MyUser,OU=MyOU,DC=MY,DC=CORP"
    
    $Group.Add($User)
    

    You have to check the contents of $CurUser AND $User variables.

提交回复
热议问题