Link to home
Start Free TrialLog in
Avatar of techdrive
techdriveFlag for United States of America

asked on

Powershell adding archive database/passing database variable in script.

Guys,

This script basically takes input from a file with the two fields populated as such below. It then creates the user on the specified mailboxdatabase under the column. This is for an exchange 2010 environment. My challenge that I have is actually getting the archive database to be the same as the mailboxdatabase. How do I incorporate this in the script I have below many thanks

user, mailboxdatabase
user1 mbb00
user3 mbb5
user20 mbb6

$mailbox=import-csv C:\temp\mailusers.CSV
ForEach ($mailbox in $mailbox) {Enable-Mailbox -Identity $Mailbox.Identity -Database $Mailbox.Database | Enable-Mailbox –Archive -ArchiveDatabase "samedatabase"}
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

$mailboxes=import-csv C:\temp\mailusers.CSV
ForEach ($mailbox in $mailboxes)
{
  Enable-Mailbox -Identity $mailbox.user -Database $mailbox.mailboxdatabase –Archive -ArchiveDatabase $mailbox.mailboxdatabase
}
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of techdrive

ASKER

You are a genius thanks again