Answered by:
Generate a random password:

Question
-
Hi all
We are currently using Exchange 2007 one 64-bit Windows Server 2008 R2 Enterprise. My system consist : AD, mailbox,HUB,Edge.
We want to create new accounts in an OU it is automatically generated password and the information each user's password into csv file
Please help me
Tuesday, August 3, 2010 7:09 AM
Answers
-
Hi,
You can use the following script to generate a random password:
--------------------------------
####Set up random number generator###
$random=new-object System.Random
####Generate a new 8 character password, the range is ASCII characters from 33 to 127###
1..8|foreach {$Password=$Password+[char]$random.next(33,127)}
add-content c:\record.log $password
-------------------------
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Thanks- Marked as answer by Gen Lin Thursday, August 12, 2010 9:05 AM
Wednesday, August 4, 2010 8:16 AM
All replies
-
Refer to these:
Creating User Accounts
http://technet.microsoft.com/en-us/library/ee198803.aspx
Create User Accounts from Information in an Excel Spreadsheet
Tuesday, August 3, 2010 7:30 AM -
Hi
you do not understand me, I want automatically generated password for new account
Tuesday, August 3, 2010 7:39 AM -
How are you creating the user accounts in AD ? Using any spreadtsheet or any third party tool ?
Tuesday, August 3, 2010 8:13 AM -
Hi
I creating the user account from Exchange Management Shell or Active Directory
1. From Exchange Management Shell
C:\Windows\System32>Import-CSV c:\a.csv | foreach {new-mailbox -alias $_.alias -name $_.name -userPrincipalName $_.email-database "First Storage Group\test" -org $_.OU -Password $Password -ResetPasswordOnNextLogon $False}.
file a.csv
Name, Alias, Email, OUThe account will be the same OU. I want generated password for all the account in OU
2. From Active Directory
I want generated password for all the account in OU
Tuesday, August 3, 2010 8:33 AM -
Refer to this article: http://technet.microsoft.com/en-us/magazine/2009.04.windowspowershell.aspx
This function can help you creating users with the predefined passwords, but not sure if it can allow you assigning random passwords:
Function CreateUser {
Param($userinfo)
New-Mailbox –UserPrincipalName $userinfo['upn']
-alias $userinfo['samAccountName']
–database $userinfo['mailboxDatabase']
–name ($userinfo['givenName'] + ' ' + $userinfo['sn'])
–organizationalUnit $userinfo['ou']
–password 'P@ssw0rd!' –FirstName ($userinfo['givenName']
–LastName $userinfo['sn'])
–DisplayName ($userinfo['givenName'] + ' ' + $userinfo['sn'])
–ResetPasswordOnNextLogon $true
}Tuesday, August 3, 2010 8:44 AM -
This function can not randow passwordTuesday, August 3, 2010 9:13 AM
-
Hi,
You can use the following script to generate a random password:
--------------------------------
####Set up random number generator###
$random=new-object System.Random
####Generate a new 8 character password, the range is ASCII characters from 33 to 127###
1..8|foreach {$Password=$Password+[char]$random.next(33,127)}
add-content c:\record.log $password
-------------------------
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Thanks- Marked as answer by Gen Lin Thursday, August 12, 2010 9:05 AM
Wednesday, August 4, 2010 8:16 AM -
Here is a couple of websites that will show you how to use random passwords in your createUser function.
http://grinding-it-out.blogspot.com/2008/10/generating-passwords-with-powershell.html
http://nex6.blogspot.com/2009/02/really-random-password-generator.html
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. If the post wasn't the exact answer or was helpful in leading you to the answer, please vote it as helpful. This can be beneficial to other community members reading the thread.- Proposed as answer by Scott H. Robinson Thursday, August 5, 2010 2:45 AM
Thursday, August 5, 2010 2:45 AM