We noticed that we had let some clients server slip through the cracks in replacing.

For us, all servers are replaced in 3 years.

So the script

Checks the install date of the server, removed that from the current date, and give a popup. If its older and needs to be replaced, it will exit with code1, cauing a flag in GFIMax

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!” _
    & strComputer & “rootcimv2”)

Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_OperatingSystem”)
For Each objItem In colItems
  cInstdate = CStr(objItem.InstallDate)

Next

srtFIrSTDATE = (Mid(cInstDate, 7, 2) & _
        “/” & Mid(cInstDate, 5, 2) & “/” &  Mid(cInstDate, 1, 4) )
       
 WScript.Echo “Server installed ” & srtFIRSTDATE
 ‘WScript.Echo Date

fromDate=CDate(srtFIRSTDATE)
toDate=CDate(date)
srtsinceinstall = (DateDiff(“d”,fromDate,toDate))

 wscript.echo “system installed ” & srtsinceinstall & ” days ago”

if srtsinceinstall >= 1005 then
wscript.echo “Need to order new server. ” & ( 1095 -srtsinceinstall) & ” days until 3 years old
WScript.Quit(1)

else
wscript.echo “server fine. ”  & ( 1095 -srtsinceinstall) & ” days until 3 years old
WScript.Quit(0)

end if

 Give it a shot, it might he

« »