Set-MsolUserPassword with a csv file

This topic contains 4 replies, has 3 voices, and was last updated by  Byron Grogan 3 years, 6 months ago.

  • Author
  • #21614

    Byron Grogan

    I am wondering whether anyone has attempted to set multiple MSOL passwords using the Set-MsolUserPassword cmdlet with a csv file?

  • #21616

    Don Jones


  • #21618

    Dave Wyatt

    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.

  • #21620

    Don Jones

    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.

  • #21622

    Byron Grogan

    This worked for me

    Import-Csv File.csv | ForEach-Object { Set-MsolUserPassword -ForceChangePassword $false -UserPrincipalName $_.UserPrincipalName -NewPassword $_.NewPassword }


You must be logged in to reply to this topic.