Is there a vbs which can give us the OS from a server list file?

Is there a vbs which can give us the OS from a server list file? A script which can write in the file the OS of each servers.
Who is Participating?
Justin OwensITIL Problem ManagerCommented:
So, you basically want a script which will:

1) Open a CSV which contains a list of servers
2) Loop through the list and
2a) Remotely scan each server to determine OS
2b) Write to the CSV the determined OS

Does that summarize your needs?

SAM2009Author Commented:
Yes that is exactly what I need! :)))
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Justin OwensITIL Problem ManagerCommented:

Doesn't your script (which is great, BTW) depend on getting info from AD rather than connecting the to listed server?  What if the computer in the list is not in AD or if AD does not have the correct OS identified?

Thanks for clarifying!

Hi, yes, it does indeed require that the Active Directory computer account exists, and also that it's accurate, but any computer that contacts the AD with it's current OS will be accurate.  If the computers are not joined to the domain, then my script is useless ;-)

Anurag_TiwariConnect With a Mentor Commented:
Option Explicit

Const ForReading = 1

Dim objWMIService, objItem, colItems
Dim strComputer, strList
Dim oFSO, sFile, oFile
Dim Stuff, myFSO, WriteStuff, dateStamp

 Set oFSO = CreateObject("Scripting.FileSystemObject")
 sFile = "c:\Servers.txt"
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
    strComputer = oFile.ReadLine
' WMI Connection to the object in the CIM namespace
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")

' WMI Query to the Win32_OperatingSystem
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
Set myFSO = CreateObject("Scripting.FileSystemObject")
' For Each... In Loop (Next at the very end)
For Each objItem in colItems
Set WriteStuff = myFSO.OpenTextFile("c:\Server-OS-Details.csv", 8, True)
WriteStuff.WriteLine(objItem.CSName & ";" & objItem.Caption & ";" & objItem.Version & ";" & objItem.CSDVersion)
Set WriteStuff = Nothing
'Set myFSO = Nothing
End If      

you can use objItem.Description,objItem.Manufacturer,objItem.CodeSet,objItem.CountryCode,objItem.OSLanguage, objItem.CurrentTimeZone,objItem.Locale,objItem.SerialNumber,objItem.SystemDrive,objItem.WindowsDirectory as well if require.
SAM2009Author Commented:
Thanks but Is it normal that I got:

Error: Permission denied:'GetObject'
From the code I posted at

which gets the information from the domain, you won't get that error, but from the code Anurag posted, you will get that if a machine from the text file is either offline, or WMI cannot be connected to on the remote machine.  There are ways around that for that script, but if you have AD, try the script I posted.


As above given script picking up the data from all the macine which would be actual data.You need to be carefull for below given things
1) You should have access rights on a machine against which you are running the script.It's would be better to run it through domain admin right.
2) It wouldn't pickup the data if a machine is offline.We can add error handling part in that so that it would give you the details why it's not picking up the data i.e. Machine offline or you don't have access to that machine.
Please let me know if i need to add that error handelling part
SAM2009Author Commented:
Sorry for the delay and thank for your helps! With those info I will be able to do something with that. Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.