Skip to content

Commit

Permalink
Improvements to password expire via domains endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 11, 2023
1 parent ede38de commit f619949
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Standards_PasswordExpireDisabled/run.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
param($tenant)
try {
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/?`$top=999&`$select=id,userPrincipalName,passwordPolicies" -tenantid $Tenant | Where-Object -Property passwordPolicies -EQ $null | ForEach-Object {
$userid = $_.id
New-GraphPostRequest -type Patch -tenantid $Tenant -uri "https://graph.microsoft.com/beta/users/$($userid)" -body '{"passwordPolicies": "DisablePasswordExpiration"}'
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/domains" -tenantid $Tenant | Where-Object -Property passwordValidityPeriodInDays -NE '2147483647' | ForEach-Object {
New-GraphPostRequest -type Patch -tenantid $Tenant -uri "https://graph.microsoft.com/beta/domains/$($_.id)" -body '{"passwordValidityPeriodInDays": 2147483647 }'
}
Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled Password Expiration" -sev Info
}
Expand Down

0 comments on commit f619949

Please sign in to comment.