Перейти к содержимому

Bulk Reset Microsoft 365 Passwords with Graph Powershell

LiftOff 365

0:00 / 0:00

Bulk Reset Microsoft 365 Passwords with Graph Powershell

2 680 просмотров · 1 год назад
LiftOff 365
1,08 тыс. подписчиков
2 680 просмотров · 1 год назад
#microsoft365 #office365 #gcc #gcchigh #powershell In this video, you'll learn how to bulk reset multiple Microsoft 365 passwords using the Microsoft Graph PowerShell module. Microsoft deprecated the Azure AD and MSonline PowerShell modules and now common tasks such as password management require Graph Powershell. Please like, comment, and subscribe! Contact us with Microsoft 365 licensing or technical questions: https://www.liftoffonline.com LiftOff365U@liftoffonline.com CHAPTERS 00:00 Intro 01:21 Create a .csv file 03:10 Connect to the Microsoft 365 tenant 04:05 Edit script 04:40 Run script 04:54 Confirm password reset 06:11 Closing Connect in the GCC High Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "Directory.ReadWrite.All", "Directory.AccessAsUser.All" -Environment USGov Connect in Commercial and Government Community Cloud Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "Directory.ReadWrite.All", "Directory.AccessAsUser.All" Password Reset Script Define the path to the CSV file $csvFilePath = "c:\temp\m365usersPass.csv" Load the CSV data into a variable $csvData = Import-Csv -Path $csvFilePath Define force password change after sign in $ForceChangePasswordNextSignIn = "true" Loop through each user in the CSV data and update their password foreach ($user in $csvData) { $userPrincipalName = $user.UserPrincipalName $userPassword = $user.Password Check if the user exists $existingUser = Get-MgUser -UserId $userPrincipalName -ErrorAction SilentlyContinue if ($null -ne $existingUser) { try { $params = @{ PasswordProfile = @{ password = $userPassword ForceChangePasswordNextSignIn = $ForceChangePasswordNextSignIn } } Update-MgUser -UserId $UserPrincipalName -BodyParameter $params -ErrorAction Stop Write-Host "Password updated for user: $userPrincipalName" -ForegroundColor Green } catch { Write-Host "Failed to update password for user: $userPrincipalName" $_.Exception.Message -ForegroundColor Red } } else { Write-Host "User not found: $userPrincipalName" -ForegroundColor Yellow } }