Mit Powershell lassen sich auch Accountdaten von Benutzern auslesen, die alle im Active Direktory vorhanden sind. Benutzung des Scripts: .\deinscript.ps1

Param(
  [string]$Username
)

function Get-Account($userName){
$expire = [datetime]::FromFileTime((Get-ADUser -Identity $UserName -Properties "msDS-UserPasswordExpiryTimeComputed")."msDS-UserPasswordExpiryTimeComputed")
return ,$expire}


function Get-ADUserLastLogon($userName)
{
  $dcs = Get-ADDomainController -Filter {Name -like "*"}
  $time = 0
  foreach($dcs in $dcs)
  { 
    $hostname = $dc.HostName
    $user = Get-ADUser $userName | Get-ADObject -Properties lastLogon 
    if($user.LastLogon -gt $time) 
    {
      $time = $user.LastLogon
    }
  }
  $dt = [DateTime]::FromFileTime($time)
  return ,$dt }

function getuser($username){
$samaccount = (Get-ADUser -Identity $UserName -Properties "SamAccountName")."SamAccountName"
$pwnever = (Get-ADUser -Identity $UserName -Properties "PasswordNeverExpires")."PasswordNeverExpires"
return $pwnever
}

function getusermail($username){
$email = (Get-ADUser -Identity $UserName -Properties "mail")."mail"
return $email
}

$PW = Get-Account -userName $userName
$LL = Get-ADUserLastLogon -userName $Username
$pwnever = getuser -Username $Username
$email = getusermail -Username $Username
[System.Windows.Forms.MessageBox]::Show("Username `t : $UserName `rLastLogon `t : $LL `rPasswort Expires `t : $PW `rPasswort Never Ex. `t : $pwnever `rEmail `t`t : $email", "Status" , 0)