Google

Tuesday, November 20, 2007

VBScript: Copy Group Membership From One Group to Anothe

Copies the group membership from one group to another (which is not possible by any GUI Tool)
Article is also available at:
http://www.microsoft.com/technet/scriptcenter/csc/scripts/ad/groups/cscad110.mspx

=========Script Code===========

strSGroupDN = InputBox ("Enter the DN of Source Group" & VBCRLF &_
vbcrlf& _
vbcrlf& _
"e.g. CN=Source Group,OU=Users,DC=NWTraders,DC=com")
strDGroupDN = InputBox ("Enter the DN of Destination Group" & VBCRLF &_
vbcrlf& _
vbcrlf& _
"e.g. CN=Destination Group,OU=Users,DC=NWTraders,DC=com")

set dicSeenGroupMember = CreateObject("Scripting.Dictionary")
set objDGroup = GetObject("LDAP://" & strDGroupDN)
DisplayMembers "LDAP://" & strSGroupDN, dicSeenGroupMember
Function DisplayMembers (strGroupADsPath, dicSeenGroupMember)
set objGroup = GetObject(strGroupADsPath)
for each objMember In objGroup.Members
objDGroup.Add("LDAP://" & objMember.distinguishedName)
next
End Function
MsgBox "Group Members have been copied to Destination Group"

=========Script Code===========

PowerShell Script: Move Mailboxes From Exchange 2003 to Exchange 2007

Moves mailboxes from Exchange 2003 to Exchange Server 2007 by reading user aliases from a text file and report errors back to text file (if any during movement).

If you want to move the mailboxes which are spread across on multiple servers, this is the better way to move those.

Article is also available at:
http://www.microsoft.com/technet/scriptcenter/csc/scripts/email/exch2007/cscem061.mspx

=========Script Code===========

# 1. Login into destination Exchange 2007 Server
# 2. Set the database name in line $TargetDatabase = "Mailbox Database" where you want to move the mailboxes
# 3. Put the list of all user's alias into c:\users.txt file
# 4. Copy this file at C:\Program Files\Microsoft\Exchange Server\scripts with name Move-Mailboxes.ps1
# 5. Run the cmdlet from Exchange Power Shell
# 6. Once all mailboxes moves check the file c:\MoveLog.txt file for any error during movement
$TargetDatabase = "Mailbox Database"
$SourceFile = "c:\users.txt"
$a = remove-item c:\Movelog.txt -ea SilentlyContinue
$error.Clear()
$UserList = Get-Content $SourceFile
foreach($user in $UserList)
{
$message = "Moving User -> " + $user
write-output $message out-file -filePath "c:\MoveLog.txt" -append -noClobber
move-mailbox -Identity $user -TargetDatabase $TargetDatabase -BadItemLimit 5 -PreserveMailboxSizeLimit:$true -Confirm: $false
if($error.Count -ne 0)
{
$message = "User " + $user + " failed to move ???????????"
write-output $message out-file -filePath "c:\MoveLog.txt" -append -noClobber
$message = "Error:::: " + $error[0].ToString()
write-output $message out-file -filePath "c:\MoveLog.txt" -append -noClobber
$error.Clear()
}
}
=========Script Code===========
Google Groups
Subscribe to IT_Discussions
Email:
Visit this group