How to save Get Logon History report

Comments

1 comment

  • Craig Whetton

    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 
    
    0
    Comment actions Permalink

Please sign in to leave a comment.