Skip to main content

Great article on setting Office 365 passwords using powershell.

http://o365info.com/manage-office-365-users-password-using/

Notice the use of $_. to refer to columns in a CSV file 

Set a Predefined Password for Office 365 user

PowerShell command Syntax
Set-MsolUserPassword –UserPrincipalName <UserPrincipalName> –NewPassword <New Password> -ForceChangePassword $False

Set a Predefined Password for Office 365 users imported from a CSV File

Step 1:
Get-MsolUser | Select UserPrincipalName|Export-CSV C:\Temp\o365users.csv

Step 2:
Import-CSV C:\Temp\o365users.csv |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName –NewPassword AbcAs123 -ForceChangePassword $False}

Creating a new user and password from a CSV file
Import-CSV –Path C:\Temp\users.csv| ForEach-Object { New-MsolUser -UserPrincipalName $_.UserPrincipalName -FirstName $_.FirstName -LastName $_.LastName  -DisplayName "$($_.FirstName) $($_.LastName)" –Password $_.Password –UsageLocation “AU” }

Comments

Popular posts from this blog