【问题标题】:Move Active Directory Group to Another OU using Powershell使用 Powershell 将 Active Directory 组移动到另一个 OU
【发布时间】:2010-09-09 17:34:25
【问题描述】:

如何使用 Powershell 将 Active Directory 组移动到另一个组织单位?

即。

我想将组“IT 部门”从:

  (CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca)

到:

  (CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca)

【问题讨论】:

    标签: powershell active-directory


    【解决方案1】:

    我还没有尝试过,但这应该可以..

    $objectlocation= 'CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca'
    $newlocation = 'OU=Temporarily Moved Groups, DC=Company,DC=ca'
    
    $from = new-object System.DirectoryServices.DirectoryEntry("LDAP://$objectLocation")
    $to = new-object System.DirectoryServices.DirectoryEntry("LDAP://$newlocation")
    $from.MoveTo($newlocation,$from.name)
    

    【讨论】:

      【解决方案2】:

      您的脚本非常接近正确(非常感谢您的回复)。

      以下脚本是我用来解决我的问题的。:

      $from = [ADSI]"LDAP://CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca"
      $to = [ADSI]"LDAP://OU=Temporarily Moved Groups, DC=Company,DC=ca"
      $from.PSBase.MoveTo($to,"cn="+$from.name)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-19
        相关资源
        最近更新 更多