I am wondering whether anyone has attempted to set multiple MSOL passwords using the Set-MsolUserPassword cmdlet with a csv file?
Yes.
Aside from not liking to put plain-text passwords into something like a CSV file, this should be pretty easy. Assuming you had a CSV file with Username and Password columns, the standard boilerplate PowerShell code could look something like this:
Import-Csv .\yourCsvFile.csv |
ForEach-Object {
Do-Something -Username $_.Username -Password $_.Password
}
I don’t know what Set-MsolUserPassword’s parameters are, off the top of my head, but you get the idea. You might need to convert the string passwords into SecureString objects first, using ConvertTo-SecureString -AsPlainText -Force , and so on.
You’d be after -NewPassword and -UserPrincipalName, both of which actually accept pipeline input ByPropertyName. So if the CSV had columns named “NewPassword” and “UserPrincipalName”…
Import-CSV Data.csv | Set-MsolUserPassword
Usually works. I usually end up using -TenantId as well, of course.
This worked for me
Import-Csv File.csv | ForEach-Object { Set-MsolUserPassword -ForceChangePassword $false -UserPrincipalName $.UserPrincipalName -NewPassword $.NewPassword }