How do I fix this so the information is in the text file? The text file is created, but has no info in it. I know I am not sending the data to the file, but I am not sure what to do to.
Get-LocalUser | Foreach-Object {
$user = $_
$lastlogon = Get-LocalUser | Where-Object {$_.lastlogon}
$date = Get-Date
New-Object -TypeName PSObject -Property @{
Date = $Date
Computer = $env:COMPUTERNAME
Name = $user.Name
Last_Logon = $user.LastLogon
}
}
$obj | out-file "c:\users\1178421472E\desktop\USERLastLogon $(Get-Date -f yyyyMMdd).txt"