Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

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

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
Mandy_
Asked:
Mandy_
  • 2
  • 2
2 Solutions
 
SubsunCommented:
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
 
Meir RivkinFull stack Software EngineerCommented:
gc c:\temp\users.csv | %{
$db =  "DB00$("{0:00}" -f (1..50 | Get-random))"
Enable-Mailbox -Identity $_ -Database $db
}

Open in new window

0
 
ChrisCommented:
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
 
SubsunCommented:
@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
 
Meir RivkinFull stack Software EngineerCommented:
I agree points should be splited
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now