Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#653 from kris6673/dev
Browse files Browse the repository at this point in the history
Small change to password expire standard
  • Loading branch information
JohnDuprey authored Mar 9, 2024
2 parents 798114f + 24b0eaa commit c2ad437
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ function Invoke-CIPPStandardPasswordExpireDisabled {
Internal
#>
param($Tenant, $Settings)
$GraphRequest = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/domains' -tenantid $Tenant
$GraphRequest = New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/domains' -tenantid $Tenant
$DomainswithoutPassExpire = $GraphRequest | Where-Object -Property passwordValidityPeriodInDays -NE '2147483647'

If ($Settings.remediate) {

if ($DomainswithoutPassExpire) {
$DomainswithoutPassExpire | ForEach-Object {
try {
New-GraphPostRequest -type Patch -tenantid $Tenant -uri "https://graph.microsoft.com/beta/domains/$($_.id)" -body '{"passwordValidityPeriodInDays": 2147483647 }'
if ( $null -eq $_.passwordNotificationWindowInDays ) {
$Body = '{"passwordValidityPeriodInDays": 2147483647, "passwordNotificationWindowInDays": 14 }'
Write-Host "PasswordNotificationWindowInDays is null for $($_.id). Setting to the default of 14 days."
} else {
$Body = '{"passwordValidityPeriodInDays": 2147483647 }'
}
New-GraphPostRequest -type Patch -tenantid $Tenant -uri "https://graph.microsoft.com/v1.0/domains/$($_.id)" -body $Body
Write-LogMessage -API 'Standards' -tenant $tenant -message "Disabled Password Expiration for $($_.id)." -sev Info
} catch {
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to disable Password Expiration for $($_.id). Error: $($_.exception.message)" -sev Error
Expand Down

0 comments on commit c2ad437

Please sign in to comment.