Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell Office 365 - Change Multiple User Passwords

$
0
0

Hi All,

I'm currently struggling to change multiple users' passwords in Office 365 and I can't quite figure out what's wrong with my code. I have the following:

Text
Connect-MsolService$tenID=(Get-MsolPartnerContract -Domain MyCustomer.onmicrosoft.com)Get-MsolUser -TenantId $tenID.TenantID.Guid | Select UserPrincipalName | Export-Csv C:\location.csv$Pass =Read-Host "Enter Password"Import-Csv C:\location.csv | % { Set-MsolUserPassword -UserPrincipalName "$_.UserPrincipalName" -NewPassword "$Pass" -ForceChangePassword $True -TenantId $tenID.TenantID.Guid }

It's the last line of code that is the issue. I'm trying to import the CSV after modifying it to suit the users I want to change. Every time I run this, however, I get:

Set-MsolUserPassword : User Not Found. User: @{UserPrincipalName=Name@MyCustomer.co.uk}.UserPrincipalName.

At line:1...


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>