Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Who has been using my computer?


03 Jun 2012   #1

MS Windows 7 Ultimate SP1 64-bit
 
 
Who has been using my computer?

Papa Bear asks: "Who has been using my computer?" Mama Bear asks:....

You get the picture. If you have one computer and several different accounts for different people, then you might find this useful:

Code:
# Start copy with very next line; Copy thru 2nd EXIT
$a = "."
$data = @()
$NetLogs = Get-WmiObject Win32_NetworkLoginProfile -ComputerName $a

foreach ($NetLog in $NetLogs) { 
if ($NetLog.LastLogon -match "(\d{14})") { 
$row = "" | Select Name,LastLogon,NumberofLogons
$row.Name = $NetLog.Name
$row.NumberofLogons = $netlog.NumberofLogons
$row.LastLogon=[datetime]::ParseExact($matches[0], "yyyyMMddHHmmss", $null) 
$data += $row 
} 
} 
$data | format-table -auto > $env:userprofile\desktop\LASTLOGON.txt

EXIT
EXIT

# Places LASTLOGON.TXT on your DESKTOP
#
# **********************INSTRUCTIONS**************************
# STEP 1 *****************************************************
# RUN PowerShell as administrator
# START ORB | type POWERSHELL | CTRL+SHIFT+ENTER key combo | YES
# ************************************************************
# STEP 2 *****************************************************
# COPY, using CTRL + C, every line down thru both EXIT statements 
# PASTE into Powershell by right-clicking at the PowerShell Prompt
#  (Ctrl V does not work)
# ************************************************************
# OUTPUT  File LASTLOGON.txt is placed on your DESKTOP
# Shows who logged on, last logon time, total number of logons
#
# ***************** NOTE - POWERSHELL VERSION*****************
# if you receive this error msg:
#  Get-WinEvent: The system can not find the path specified
# you need to update your PowerShell
# you must be using Powershell 2.0 or later.
#
# To determine your Powershell version:
#   Run PowerShell
#   enter following $host.version
#   you should see at least:
# Major  Minor  Build  Revision
# -----  -----  -----  --------
# 2      0      -1     -1
#
# If you do not see the above, update your Vista/Win 7.
# ************************************************************
#
# *************** NOTE - EXECUTION POLICY*********************
# If you haven't set the execution policy, you may need to:
#   Run PowerShell
#   enter following without the #
#   Set-ExecutionPolicy -executionpolicy remotesigned
#
# ************************************************************
#
# *************************SCRIPT NOTES***********************
# $a a period indicates this computer, use actual name if desired
# $data defined as empty array
# match will compare against a 'regular' expression
# if match exist, returns true, result placed in $matches array
#



My System SpecsSystem Spec
.

Reply

 Who has been using my computer?




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:05 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33