Solved

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

Posted on 2011-03-22
10
372 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:Justin Owens
ID: 35193652
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
ID: 35194025
Yes that is exactly what I need! :)))
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 35195172
0
 
LVL 31

Expert Comment

by:Justin Owens
ID: 35195716
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
ID: 35195897
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 3

Assisted Solution

by:Anurag_Tiwari
Anurag_Tiwari earned 250 total points
ID: 35199128
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
ID: 35204148
Thanks but Is it normal that I got:

Error: Permission denied:'GetObject'
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35204250
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
ID: 35204917
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
ID: 35238042
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

24 Experts available now in Live!

Get 1:1 Help Now