Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

How to save Get Logon History report

Gadzooks! I just found the Get Logon History for my devices in Inventory! After the Powershell runs, how can I extract/save that report as a TXT or other? Thanks!



1 comment
Date Votes
  • We have a copy of the script set to export to our own desktop. This is at the start of the script. There are probably better ways of doing this.

    $folder = 'logins'
    Write-Host ""
    $Path = "$env:userprofile\desktop"
    Set-Location -path $Path
    If((Test-Path $folder)-eq $True){ #if folder exists
    Write-Host -ForegroundColor Yellow "$Folder folder cannot be created at $Path - as it already exists"
    Else{ #if folder doesn't exist
    New-Item -Path $Folder -ItemType "Directory" | Out-Null
    Write-Host -ForegroundColor Green "$Folder created at $path"
    $Logins = "$Path\$Folder" 

    Then this is added onto the last line

    | out-file $logins\$(Computer:TARGET).txt