$weeks = 4 # first, find out the AD time format from # 4 weeks ago that will be used in the LDAPFilter
$today = Get-Date # 4 weeks ago $cutDate = $today.AddDays(-($weeks * 7)) # translate in AD time format $cutDateAD = $cutDate.ToFileTimeUtc()
# next, find a way to convert back the AD file format $realDate = @{ Name = 'Date' Expression = { if ($_.pwdLastset -eq0) { '[never]' } else { [DateTime]::FromFileTimeUtc($_.pwdLastset) } }
$all.Properties | ForEach-Object { [PSCustomObject]@{ # attention: property names on right side are case-sensitive! Name = $_.name[0] DN = $_.distinguishedname[0] } } } }
# make sure you specify a valid distinguishedname for a user below Get-NestedGroupMember-distinguishedName'CN=UserName,DC=powershell,DC=local'