Windows – How to determine logon/logoff times in Windows Powershell without admin rights

powershellwindowswindows 7

In order to determine logon and logoff times for a given day on my Windows PC, I've used the following script in Windows PowerShell run as administrator:

Get-WinEvent -FilterHashtable @{starttime='5/6/2018';endtime='5/7/2018';logname='security';id=4648,4634}

I've tried and determined that the above does not work when PowerShell is not run as administrator. Local admin privilege will soon be taken away on the PC on which I need to run this script – which I think means I will no longer be able to run PowerShell as administrator. Is there an alternative that I can run from Powershell or the standard CLI by which I can determine logon and logoff times for a given day?

If relevant, the PC is running Windows 7 Enterprise.

Best Answer

You could create a scheduled task which is activated whenever one of the relevant events occurs, and writes the desired event info to a log file which is accessible to your non-admin user.

Related Question