Announcement

Collapse
No announcement yet.

Display accounts expiration dates from list of users

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Display accounts expiration dates from list of users

    Hi!
    Is there a simple way to display expiration dates of accounts based on a list of usernames from a text file and export it to another text file?

    Thanks!

  • #2
    Here a sample,

    Code:
    $Today = [datetime]::Today
    $MaxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.TotalDays
    
    [email protected](
      @{n="AccName";e={$_.sAMAccountName}}
      @{n="AccExpDate";e={$_.AccountExpirationDate}}
      @{n="AccIsExpired";e={$($_.AccountExpirationDate -ne $null) -and ($_.AccountExpirationDate -le $Today)}}
      @{n="AccIsDisabled";e={$($_.Enabled -eq $false)}}
      @{n="AccIsLockedOut";e={$_.LockedOut}}
      @{n="PwIsExpired";e={$($_.PasswordLastSet.AddDays($MaxPasswordAge) -le $Today)}}
     )
    
    Get-Content "c:\USERS.txt" | Get-ADUser -properties AccountExpirationDate,LockedOut,PasswordLastSet | Select-Object $props | Export-Csv "C:\exportusers.csv" -notypeinfo
    Last edited by Rems; 17th December 2015, 21:53.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X