Solved

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

Posted on 2011-03-22
10
360 Views
Last Modified: 2012-08-14
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.
0
Comment
Question by:SAM2009
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 31

Expert Comment

by:DrUltima
Comment Utility
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?

DrUltima
0
 
LVL 1

Author Comment

by:SAM2009
Comment Utility
Yes that is exactly what I need! :)))
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
Comment Utility
0
 
LVL 31

Expert Comment

by:DrUltima
Comment Utility
Rob,

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!

DrU
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
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 ;-)

Rob.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 3

Assisted Solution

by:Anurag_Tiwari
Anurag_Tiwari earned 250 total points
Comment Utility
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)
WriteStuff.Close
Set WriteStuff = Nothing
Next
Loop
'Set myFSO = Nothing
oFile.Close
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.
0
 
LVL 1

Author Comment

by:SAM2009
Comment Utility
Thanks but Is it normal that I got:

Error: Permission denied:'GetObject'
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
From the code I posted at
http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_26757481.html

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.

Regards,

Rob.
0
 
LVL 3

Expert Comment

by:Anurag_Tiwari
Comment Utility
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
0
 
LVL 1

Author Closing Comment

by:SAM2009
Comment Utility
Sorry for the delay and thank for your helps! With those info I will be able to do something with that. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now