Solved

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

Posted on 2013-05-20
7
506 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
To show how to create a transport rule 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 >> Rules tab.:  To cr…

733 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