Skip to content

Instantly share code, notes, and snippets.

@davegreen
Last active December 19, 2015 12:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davegreen/5956874 to your computer and use it in GitHub Desktop.
A function that can be passed a date from AD, such as the lastlogon attribute and returns a string of the date, or the string 'Never'.
# Returns a date string based on an AD attribute (like lastlogon, or accountexpires).
# Param1: $addate - AD attribute date value.
Function Get-ADDate($addate)
{
Try
{
$formatteddate = [datetime]::FromFileTime($addate).Date.ToString()
}
Catch
{
$formatteddate = "Never"
}
return $formatteddate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment