ChangePW.ps1
|
$allUsers = Get-Mguser -All | Where-Object { $_.UserPrincipalName -notin @("natascha@dyrlaege.dk","jyskit@dyrlaege.onmicrosoft.com") } $allUsers | ForEach-Object { $user = $_ $licenses = Get-MgUserLicenseDetail -UserId $user.Id if ($licenses) { Write-Host "Updating ForceChangePassword for user: $($user.UserPrincipalName)" -ForegroundColor Green Update-MgUser -UserId $user.Id -PasswordProfile @{ ForceChangePasswordNextSignIn = $true } } } |