I need a script that reads from a txt file (a computer list) and returns how much time do we have before the Daylight savings starts.
Here's my script so far:
strComputer = "C:\temp\computerlist.txt"
For Each computer in strComputer
For Each objItem in colItems
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
dtmTime = CDate(strTime)
Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next
Next
DayLightSavingTimes=CDate("21/10/2013 00:00:00")
wscript.echo("It is " & DateDiff("m", Now(), DayLightSavingTimes) & " Months to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("d", Now(), DayLightSavingTimes) & " days to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("h", Now(), DayLightSavingTimes) & " hours to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("n", Now(), DayLightSavingTimes) & " Minutes to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("s", Now(), DayLightSavingTimes) & " seconds to the DayLightSavingTimes!")
When I ran this for one single computer it works:
strComputer = "MyComputer"
WScript.Echo "Running Against Remote Computer Named: " & strComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
For Each objItem in colItems
strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
dtmTime = CDate(strTime)
Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next
DayLightSavingTimes=CDate("21/10/2013 00:00:00")
wscript.echo("It is " & DateDiff("m", Now(), DayLightSavingTimes) & " Months to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("d", Now(), DayLightSavingTimes) & " days to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("h", Now(), DayLightSavingTimes) & " hours to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("n", Now(), DayLightSavingTimes) & " Minutes to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("s", Now(), DayLightSavingTimes) & " seconds to the DayLightSavingTimes!")
And I get the expected results:
Running Against Remote Computer Named: MyComputer
14:28:22
It is 0 Months to the DayLightSavingTimes!
It is 3 days to the DayLightSavingTimes!
It is 58 hours to the DayLightSavingTimes!
It is 3452 Minutes to the DayLightSavingTimes!
It is 207098 seconds to the DayLightSavingTimes!
I need to get the same results running this on remote machines, stored on computerlist.txt The error I get running it remotely is Microsoft VBScript runtime error: Object not a collection.
Any hints?
Thanks