Wow, this one has all kinds of errors. Can you send it to me in a text file? I think outlook mashed it. I can't even get it to run.
Thanks! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Derek Harris Sent: Wednesday, May 24, 2006 5:05 PM To: [email protected] Subject: RE: [ActiveDir] OT help with VBS/WMI Script Here's what I use; you can replace the commas with + if you like, but the quotes make Excel ignore the comma in the os caption. >>>>>>>>>>>>>>>>> On Error Resume Next DomainString=Inputbox("Enter the domain name","Check Active Computers","YOUR DOMAIN HERE") oFileName = "CompOSList.csv" if DomainString="" then wscript.echo "No domain specified or script cancelled." wscript.quit end if Set DomainObj = GetObject("WinNT://"&DomainString) if err.number<>0 then wscript.echo "Error connecting to " & DomainString wscript.quit end if Set FSO = CreateObject("Scripting.FileSystemObject") Set oFile = FSO.CreateTextFile(oFileName, True) DomainObj.Filter = Array("computer") 'Wscript.echo "Computer Accounts in " & DomainString For each Computer in DomainObj err.clear strComputer = Computer.Name strOutput = strOutput & strComputer & "," Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") If err.number=0 then Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems strOutput = strOutput & Chr(34) & objOperatingSystem.Caption & Chr(34) & "," & objOperatingSystem.Version & vbCrlf Next Else strOutput = strOutput & vbCrlf End If Next oFile.WriteLine strOutput set DomainObj=Nothing set Shell=Nothing Wscript.quit >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hutchins, Mike Sent: Wednesday, May 24, 2006 4:03 PM To: [email protected] Subject: [ActiveDir] OT help with VBS/WMI Script So I am trying to get some information from a gigantic list of machines. Problem is that if the machine isn't up, the script retains the previous values. Example server1+Microsoft(R) Windows(R) Server 2003, Enterprise Edition+5.2.3790 server2+Microsoft(R) Windows(R) Server 2003, Enterprise Edition+5.2.3790 In this example Server1 is Accurate (the "+" is a delimiter) Server2 is not online so the script retained the OS.Caption and OS.Version part. I would rather it be blank like; server2++ Here is the script part that this lies in. Any suggestions greatly appreciated. For Each strComputer In serverList Set colSettings = "" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each OS In colSettings WScript.Echo strComputer + "+" + OS.Caption + "+" + OS.Version Next Next List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.activedir.org/ml/threads.aspx List info : http://www.activedir.org/List.aspx List FAQ : http://www.activedir.org/ListFAQ.aspx List archive: http://www.activedir.org/ml/threads.aspx
