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"}
PowershellExchange

Avatar of undefined
Last Comment
techdrive

8/22/2022 - Mon
Raheman M. Abdul

$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
Subash Sundharan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
techdrive

You are a genius thanks again
Your help has saved me hundreds of hours of internet surfing.
fblack61