PowerShell的非的cmdlet:通过System.DirectoryServices中的命名空间将用户添加到新的OU [英] Powershell NON-Cmdlet: Move User to new OU via System.DirectoryServices Namespaces

查看:455
本文介绍了PowerShell的非的cmdlet:通过System.DirectoryServices中的命名空间将用户添加到新的OU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我登录的域Y和与我想移动位于域X(Windows 2003的服务器,而不ADAM)的用户的AD

I am logged in on domain Y and the AD with the User I wish to move is located in domain X (windows 2003 server without ADAM)

将如何从一个OU向另一个OU通过System.DirectoryServices中的命名空间的方法同一个域中的一招用户X?

How would one move user X from an OU to another OU within the same domain through the System.DirectoryServices Namespaces method?

这是多远,我已经得到了:

This is how far I've gotten:

$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($context, $idtype, $sam)

没有说明这里:<一href="http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal.aspx"相对=nofollow> UserPrincipal

推荐答案

下面是一个其他的解决办法:

Here is an other solution :

# MoveObject
$OuDest=[ADSI] "LDAP://mach:389/ou=Commerciaux,dc=societe,dc=fr" 
$objUODest.MoveHere("LDAP://cn=Mickey,ou=Ventes,dc=societe,dc=fr", "cn=Mickey")

# Rename
$Ou=[adsi] "LDAP://mach:389/ou=Ventes,dc=societe,dc=fr"
$Ou.MoveHere("LDAP://cn=PetitMickey,ou=Ventes,dc=societe,dc=fr", "cn=PetitMickeyBis")

如果您需要authentify:

If you need to authentify :

$OuDest = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://FQDN name or @IP",$User,$password)

这篇关于PowerShell的非的cmdlet:通过System.DirectoryServices中的命名空间将用户添加到新的OU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆