?
Solved

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

Posted on 2013-05-20
7
Medium Priority
?
514 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 1000 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
In this video we show how to create an email address policy 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 Mail Flow…
Suggested Courses

777 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