Direct Inward Dialing: +1 408 916 9892
The following is a comparison between the procedures for identifying users logged on to remote computer using Windows PowerShell and ADAudit Plus:
Import-Module ActiveDirectory
Get-RDUserSession -ConnectionBroker connection-broker-name
{
$dcs = Get-ADDomainController -Filter {Name -like "*"}
$users = Get-ADUser -LDAPFilter "(&(objectCategory=person)(objectClass=user))"
$time = 0
$exportFilePath = "c:\scripts\lastLogon.csv"
$columns = "name,username,datetime"
Out-File -filepath $exportFilePath -force -InputObject $columns
foreach($user in $users)
{
foreach($dc in $dcs)
{
$hostname = $dc.HostName
$currentUser = Get-ADUser $user.SamAccountName | Get-ADObject -Server $hostname -Properties lastLogon
if($currentUser.LastLogon -gt $time)
{
$time = $currentUser.LastLogon
}
}
if($time -eq 0){
$row = $user.Name+","+$user.SamAccountName+",Never"
}
else {
$dt = [DateTime]::FromFileTime($time)
$row = $user.Name+","+$user.SamAccountName+","+$dt
}
Out-File -filepath $exportFilePath -append -noclobber -InputObject $row
$time = 0
}
}
Following are the limitations in obtaining every user logged on to remote computers using native tools like Windows PowerShell:
ADAudit Plus will automatically scan all DCs in the domain to retrieve information about the users currently logged on remotely to a computer, generate the report and present it in a simple and intuitively designed UI.