by Administrator
12. January 2009 11:01
It turns out that whilst you can happily create a new mailbox in any OU you want, you cannot then move it to a different OU using the set-mailbox command. In fact what you have to do, is move the base Active Directory object. To do this you need to know (or work out) the distinguished name of both the user you are trying to move, and the OU you are trying to move it to. You then use the MoveTo method of the PSBase Object to move it. The code to do this looks like this:
[sourcecode]
"$from=[ADSI] 'LDAP://<DIstinguisedNameOfUser>'"
"$to=[ADSI] 'LDAP://'<DistinguisedNameofOUToMoveTo>"
"$from.PSBase.MoveTo($to)"
[/sourcecode]
On a side not. The PSBase object, basically gives you access to teh underlying Powershell Object, not the specilised version for a user, mailbox etc. A good explanantion is availible here.
http://blogs.msdn.com/powershell/archive/2006/11/24/what-s-up-with-psbase-psextended-psadapted-and-psobject.aspx
0f61e586-7f76-4355-9808-bfa82d64b809|0|.0
Tags: