Solved

Powershell calculate number between 1 and 50 to use variable exchange databases

Posted on 2013-05-20
7
511 Views
Last Modified: 2013-05-31
Hi,

i like to enable mbx of a lot of user from a CSV but i want to use different databases between
DB0001 and DB0050. How can i create this to use with following cmd-

Enable-Mailbox -Identity $User.UserID -Database DB0001

appreciate for your help
mandy
0
Comment
Question by:Mandy_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 250 total points
ID: 39180234
If you are looking for random numbers then try with Get-random
Enable-Mailbox -Identity $User.UserID -Database "DB00$("{0:00}" -f (1..50 | Get-random))"

Open in new window

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39180247
gc c:\temp\users.csv | %{
$db =  "DB00$("{0:00}" -f (1..50 | Get-random))"
Enable-Mailbox -Identity $_ -Database $db
}

Open in new window

0
 
LVL 12

Expert Comment

by:Chris
ID: 39180628
Incidentally, if you don't specify a database when creating a mailbox,
exchange will load balance the mailboxes across all available databases automatically.

Depending on your setup, this may be redundant code.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39194491
@Mandy_, May I ask you the reason you selected Sedgwick's commend as answer? In fact, I did provide the method to get random numbers. Sedgwick just elaborated it using same method. A split in points would be more fair.. :-)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39198167
I agree points should be splited
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question