Last logon active directory


best,

i want see last logon of users in our ad (win2k8). im such noob in scripting etc. found script on here do?
want have script lets see username, last logon time , has saved .csv file or it.
users in ad in different user ou's possible them @ once?

the users settled in icl-ips (local) > zicl ip hd > ipt > users
below ou 7/8  containers users.

can pls thank you,

regards,
kevin

ps. script found

$user = $args[0]
$domain = $args[1]
 
$domain = $domain.tolower()
 
#suppress errors dc's have computer accounts not connected domain
$erroractionpreference = [system.management.automation.actionpreference]::silentlycontinue
$warningpreference = [system.management.automation.actionpreference]::silentlycontinue
 
switch($domain)
{
    domain1 {$dom = "icl-ips.com"}
}
 
connect-qadservice -service $dom
 
get-qadcomputer -computerrole domaincontroller -activity "compiling domain controllers in $domain" | % {
$dc = $_.name
get-qaduser -service $dc -samaccountname $user } | sort-object lastlogon -descending | select-object name, lastlogon -first 1

 



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...