In Part II I’ve explained how to create bulk users using CSV file, and how to create the CSV file.

In this part we will discuss some of the management tasks including password.

Users Bulk Import with Password

In Part II I’ve explained how to prepare the CSV, create the users with randomly generated password, which will require sending this password later to the users, check the following report after creating the users:

clip_image002

In large environments it may be required to create users with password (could be generated from ID as an example) and of course enforce the user to change it once logon, check the following cmdlet:

Import-Csv D:\arab-users.csv | ForEach-Object -Process {New-MsolUser -UserPrincipalName $_.upn -FirstName $_.firstname -LastName $_.lastname -Department $_.department -Title $_.title -City $_.city -Country $_.country -DisplayName $_.displayname -LicenseAssignment meamcs:ENTERPRISEPACK -UsageLocation EG -Password $_.password -ForceChangePassword $true} | Export-Csv -Path c:\arabusers-result.csv -Encoding unicode

In the above cmdlet we have completed the following:

1. Create the users in the CSV file with the mentioned attributes.

2. Assign license with usage location (which is required).

3. Set each user’s password according to the value in the CSV file.

4. The user will be forced to change the password on the next logon ($true is the default value).

5. Export the result in CSV file.

Let’s first discuss the second point how I got LicenseAssinment value, run the following cmdlet to get the license in your tenant:

05-01

Last thing is to make sure that the password will be according to the below conditions:

- Use 8 to 16 characters.

- Create a strong password. Office 365 requires at least 3 of the following:

o Lowercase characters

o Uppercase characters

o Numbers (0-9)

o Symbols, including: ! @ # $ % ^ & * - _ + = [ ] { } | \ : ‘ , . ? / ` ~ “ < > ( ) ;

- Don’t use the user name (the part of your user ID to the left of the @ symbol).

- UNICODE values are not allowed, so no Arabic password J

Users Bulk Modify

After creating users it may be required to modify users’ attributes, so we will need to have our CSV file ready as per the Part II, then the following cmdlet shows an example of modifying some attributes:

Import-Csv D:\arab-users.csv | ForEach-Object -Process {Set-MsolUser -UserPrincipalName $_.upn -FirstName $_.firstname -LastName $_.lastname -Department $_.department -Title $_.title -City $_.city -Country $_.country -DisplayName $_.displayname -UsageLocation EG -PasswordNeverExpires $true} | Export-Csv -Path d:\arabusers-result.csv -Encoding unicode

Note:

1. From the CSV and for each user with this UserPrincipalName value ($_.upn) we have modified all of the above attributes to the values in the CSV file.

2. UsageLocation value has been used with the same cmdlet.

3. Password Never Expire has been allowed, so the password will not expire (the default is the password will expire every 90 days).

The following can’t be done from this cmdlet:

1. Change the User Principal Name, which can be done through the following cmdlet:

Import-Csv C:\ newupn.csv | ForEach-Object -Process {Set-MsolUserPrincipalName -UserPrincipalName $_.upn -NewUserPrincipalName $_.upn1}

2. Resetting the password, which can be done by the following cmdlet:

Import-Csv d:\arab-userspassword.csv | ForEach-Object -Process {Set-MsolUserPassword -UserPrincipalName $_.upn -NewPassword $_.password}

3. Assign license to the users, and this can be done by using the following cmdlet:

Import-Csv d:\arab-userslicense.csv | ForEach-Object -Process {Set-MsolUserLicense -UserPrincipalName $_.upn -AddLicenses "meamcs:ENTERPRISEPACK"

Last nice trick to modify everything in one cmdlet by pipeline all the above cmdlets as the following:

Import-Csv -Path C:\arabusers.csv | ForEach-Object -Process {Set-MsolUser -UserPrincipalName $_.upn -UsageLocation EG | Set-MsolUserLicense -UserPrincipalName $_.upn -AddLicenses "meamcs:ENTERPRISEPACK" | Set-MsolUserPassword -upn $_.userprincipalname -NewPassword $_.password}

And don’t forget the “” with the license.

I hope the above cmdlets were useful and saved time of trying and searching how to do it. In the next part I will explain the reports and Dynamic Distribution Groups.

Other parts:

Part I: Arabic Problems

Part II: Users Bulk Creation

Part III: Users Bulk Modification

Part IV: Dynamic Distribution Group