Azure CSV Import to update users Password Never Expire

Viewed 70

I'm trying to import a CSV file to do a bulk service accounts and change to password never expire in Azure. I think it loop is called foreach.

$connect = Connect-AzureAD -AccountId $env:USERNAME@company.com
Set-AzureADUser -ObjectId test01@company.com -PasswordPolicies DisablePasswordExpiration
1 Answers

I think it loop is called foreach

Yes, Use the foreach to do bulk operation.

Workaround follows:

# you can use the below code for bulk opertation
Import-CSV "<user file>" | foreach {
 Set-AzureADUser -ObjectId $_.UserPrincipalName -PasswordPolicies DisablePasswordExpiration
}

Result

enter image description here Changes applied in Azure AD enter image description here

Related