Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
crazylife din Bucuresti
Femeie
25 ani
Bucuresti
cauta Barbat
25 - 47 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [WINDOWS] Extract Logon and Logoff Times to Notepad Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
I just adapted the code from Source 1 a bit in order to export to txt instead of csv, and then open the txt file.

Notepad will contain times and Logon/Logoff IDs, which are:
ID 7001 = Logon
ID 7002 = Logoff

First off, copy the following code to notepad and save the file with ps1 extension, eg. D:\Get Login-Logon Times.ps1


$filter = @{
    Logname = 'System'
    ID = 7001, 7002
    ProviderName = 'Microsoft-Windows-Winlogon'
}
Get-WinEvent -FilterHashtable $filter -MaxEvents 50 |
     Select TimeCreated, ID |
     Out-File D:\Times.txt

Start notepad D:\Times.txt


You cannot open the ps1 file with double click for security reasons.
But you can bypass that by creating a shortcut (New - Shortcut) with the following syntax for the item location. Then double click the shortcut to generate and open the notepad file.


powershell.exe -command "& 'D:\Get Login-Logon Times.ps1'


If using the above command the shortcut doesn't generate and open the txt file, see the post below.

Sources:
1.
2.


_______________________________________


pus acum 2 ani
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
Upon a fresh Windows install I found out that the above command won't work.

Tried:
- enabling developer mode
- setting the shortcut to run as administrator

Both didn't work.

What worked was changing a bit the command to the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& 'D:\Get Login-Logon Times.ps1'


And for an even shorter powershell window display:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle hidden -Command "& 'D:\Get Login-Logon Times.ps1'


And without showing any window (except for the windows terminal appearing shortly on taskbar) you can pass it through cmd:

cmd.exe /c start /min "" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& 'D:\Get Login-Logon Times.ps1'


Spurce:


_______________________________________


pus acum 1 an
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
In Task Scheduler, to open the script at startup, under Actions:

Program/script: cmd.exe
Additional arguments: /c start /min "" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& 'D:\Get Login-Logon Times.ps1'

More options:


_______________________________________


pus acum 1 an
   
Pagini: 1  

Mergi la