'=========================================
For Each strComputer In serverList
      Set colSettings = ""
      Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     Set colSettings = objWMIService.ExecQuery _
      ("Select * from Win32_OperatingSystem")

    If err then
         WScript.Echo strComputer + "++"
    else
        Set colSettings = objWMIService.ExecQuery _
       ("Select * from Win32_OperatingSystem")
       For Each OS In colSettings'
          WScript.Echo strComputer + "+" + OS.Caption + "+" + OS.Version
       Next
    end if
Next
'=========================================

Rgds,
Tim


On 5/25/06, Hutchins, Mike <[EMAIL PROTECTED]> wrote:
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/

Reply via email to