• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

How to know what's the last time the server has been accessed?

I have a Windows 2003 server which is closed for a while and I don't know why it was closed. I need to know what is the last time the server has been accessed without open it. Is there a way to check that?
  • 2
  • 2
2 Solutions
Mike KlineCommented:
What do you mean closed?  Have you looked through the security event logs on the server?


SAM2009Author Commented:
By close I mean it turns off but I don't know why it was shutdown that explain I just want to know how to check the last time someone was connected in the server. If it was shutdown for more than 1 year so I will not waste my time and leave it like that.

Could we check last connection in AD?
Mike KlineCommented:
If you were to turn it on you could check the event logs on that box

In AD you could check the lastlogontimestamp attribute for that box.  Note that attribute is accurate within 10-14 days   http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx


Hi ,
We using the below VB script to audit users logs on, assign the script as a log in to all users, or assing in to the ou that the server in and enable loop back.

Hope that helps

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
    SerialNumber = trim(objItem.SerialNumber)

Dim Manufacturer 
Dim Model 
Dim MachineName  
Dim SerialNumber 
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
	Manufacturer = Trim(objItem.Manufacturer) ' manufacturer
    Model = trim(objItem.Model)		' pc model
    MachineName  = trim(objItem.Name)		' computer netbios name


Dim TotalVisibleMemory 
Dim OperatingSystemAndServicePack 
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem In colItems
   cOSs = objItem.Name
   pos = InStr(1, cOsS,"|",1)
   cOS1 = left(cOSs,pos-1)
   OperatingSystemAndServicePack =  cOS1 & " " & objItem.CSDVersion
   'TotalVisibleMemory = objItem.TotalVisibleMemorySize
   TotalVisibleMemory = FormatNumber(objItem.TotalVisibleMemorySize/1024,0) + " MEG" 

Dim ProcessorAndClockSpeed 
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem in colItems
ProcessorAndClockSpeed= trim(objItem.Name) & " /" & objItem.CurrentClockSpeed & " MHz"

Dim UserName
set oNet = CreateObject("WScript.Network") 
UserName = oNet.UserName

set wshShell1=Wscript.CreateObject("Wscript.Shell")
set logonserver= WshShell1.ExpandEnvironmentStrings("%logonserver%")

UpdateList UserName,MachineName,Manufacturer,Model,SerialNumber,ProcessorAndClockSpeed,TotalVisibleMemory,OperatingSystemAndServicePack,Width,Height,WshShell1.ExpandEnvironmentStrings("%logonserver%")

Function UpdateList(UserName,MachineName,Manufacturer,Model,SerialNumber,ProcessorAndClockSpeed,TotalVisibleMemory,OperatingSystemAndServicePack,Width,Height,logonserver)
	Dim filename
	filename = "\\share\Logon.csv"
	Const Appending = 8
	Const a = """" ' used at begginging & end
	Const b = """,""" ' used everywhere else.
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.OpenTextFile(filename, Appending, False)
	f.WriteLine(a &UserName& b & MachineName & b & Manufacturer& b & Model& b & SerialNumber& b & ProcessorAndClockSpeed& b & TotalVisibleMemory& b & OperatingSystemAndServicePack& b & Width& b & Height& b & logonserver& b &Now()& a)

end Function

Function ScreenResolution()
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
Do Until .readyState = 4: wscript.sleep 100: Loop
width = .document.ParentWindow.screen.width
height = .document.ParentWindow.screen.height
End With
ScreenResolution = array(width,height)
End Function

Open in new window

SAM2009Author Commented:
Many thanks!

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now