Solved

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

Posted on 2011-03-22
10
385 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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
 
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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

Suggested Solutions

In-place Upgrading Dirsync to Azure AD Connect
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 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