Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Out-File Blank

$
0
0

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"


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>