Quick script to reset password of users in an Azure AD group

Connect-AzureAD

# Get group by name
$group = Get-AzureADGroup -SearchString 'My group'

# Get members
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All:$true 

# Get password
$password = Read-host -AsSecureString -Prompt "Password"

$VerbosePreference = "Continue" 
$inc = 1
$members | Foreach {
    Write-Verbose "$($inc) / $($members.Count) - $($_.UserPrincipalName)"
    $inc += 1

    Set-AzureADUserPassword -ObjectId $_.ObjectId -ForceChangePasswordNextLogin:$true -Password $password
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s