SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getLastLogonTS{
  2.     param($username)
  3.     $DCs = Get-ADDomainController -Filter *| Select hostname
  4.     foreach($d in $DCs) {
  5.         $lasttime = $(Get-ADUser -Properties lastlogontimestamp $username -Server $d.hostname).lastlogontimestamp
  6.         if($lasttime -gt $lastLogonTimestamp){
  7.             $lastLogonTimestamp = $lasttime
  8.         }
  9.     }
  10.         return [datetime]::fromFileTime($lastLogonTimestamp)
  11. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top