PoshCode Logo PowerShell Code Repository

Difference between
modified post 6777 by gfilice on Wed 8th Mar 13:32 and
original post 2939 by AlphaSun on Wed 31st Aug 14:43
Showold version | new version | both versions

    
11
function Get-DomainPasswordPolicy
33
{
44
	$domain = [ADSI]"WinNT://$env:userdomain"
55
	$Name = @{Name="DomainName";Expression={$_.Name}}
66
	$MinPassLen = @{Name="Minimum Password Length (Chars)";Expression={$_.MinPasswordLength}}
77
	$MinPassAge = @{Name="Minimum Password Age (Days)";Expression={$_.MinPasswordAge.value/86400}}
88
	$MaxPassAge = @{Name="Maximum Password Age (Days)";Expression={$_.MaxPasswordAge.value/86400}}
99
	$PassHistory = @{Name="Enforce Password History (Passwords remembered)";Expression={$_.PasswordHistoryLength}}
1010
	$AcctLockoutThreshold = @{Name="Account Lockout Threshold (Invalid logon attempts)";Expression={$_.MaxBadPasswordsAllowed}}
1111
	$AcctLockoutDuration =  @{Name="Account Lockout Duration (Minutes)";Expression={if ($_.AutoUnlockInterval.value -eq -1) {'Account is locked out until administrator unlocks it.'} else {$_.AutoUnlockInterval.value/60}}}
1212
	$ResetAcctLockoutCounter = @{Name="Reset Account Lockout Counter After (Minutes)";Expression={$_.LockoutObservationInterval.value/60}}
1313
	$domain | Select-Object $Name,$MinPassLen,$MinPassAge,$MaxPassAge,$PassHistory,$AcctLockoutThreshold,$AcctLockoutDuration,$ResetAcctLockoutCounter
1414
}

ContributeMost Recent Contributions (feed)

Contribute ... Next Page