X-Received: by 10.237.59.8 with SMTP id p8mr744627qte.1.1473355730236; Thu, 08 Sep 2016 10:28:50 -0700 (PDT) X-Received: by 10.157.18.211 with SMTP id g77mr192526otg.19.1473355730166; Thu, 08 Sep 2016 10:28:50 -0700 (PDT) Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!m9no1801903qte.0!news-out.google.com!b4ni12940iti.0!nntp.google.com!i184no4888itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: microsoft.public.scripting.vbscript Date: Thu, 8 Sep 2016 10:28:49 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=15.65.252.15; posting-account=B9cL2QoAAAC9wP2TmxuAsW1eE6AsJi5E NNTP-Posting-Host: 15.65.252.15 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Query HBA for attached disks and drives. From: =?UTF-8?B?Q8Opc2FyIEFyw6l2YWxv?= Injection-Date: Thu, 08 Sep 2016 17:28:50 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 5898 X-Received-Body-CRC: 3588991893 Xref: csiph.com microsoft.public.scripting.vbscript:11386 Hello team, I'm trying to query the HBA cards on several servers to obtain HBA's info, = but more important, I need to obtain what are the associated disks that com= es from storage. Having this information, I will be able to obtain then, i= ts used space and its free space. According to MS the class HBAScsiID has the "OSDeviceName" which is the att= ribute I need to know to obtain the drive information. The problem is that= the class is not responding back with information, it always shows nothing= . The function is "QueryHBAScsiID". Can you guys please point me in the right direction on how to make this wor= k? Here's my code. Sorry for the indentation... I swear it looks good in my fi= le! LOL! =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dim strComputer : strComputer =3D "." WScript.Echo QueryHBA(strComputer) ' Function to obtain the drive from a FLTMC format: "\Device\HarddiskVolume= 3" function GetDriveLetterByFLTMC(strComputer, strDrive) Dim Result : Result =3D "" Dim strCommand, strVolume =20 Result =3D "" strVolume =3D LCase(strDrive) strVolume =3D Replace(strVolume, "\\\\", "\") =20 strCommand =3D "fltmc volumes | find /i " & QuotedStr(strVolume) Result =3D Trim(ExecuteCommand(strCommand)) if Result <> "" then Result =3D Split(Result, " ")(0) end if =20 if Len(Result) =3D 2 then GetDriveLetterByFLTMC =3D Result else Result =3D "N/A" end if =20 GetDriveLetterByFLTMC =3D Result end function function ExecuteCommand(StrCMD) Dim objShell, objExecObject Dim strCommand, Result =09 Set objShell =3D CreateObject("WScript.Shell") strCommand =3D "%comspec% /c " & StrCMD Set objExecObject =3D objShell.Exec(strCommand) Result =3D objExecObject.StdOut.ReadAll() ExecuteCommand =3D Result end function ' function that queries HBA cards function QueryHBA(StrComputer) On Error Resume Next =20 Dim objWMIDisk, colItem, objItem Dim Result : Result =3D "" Dim HBAExists : HBAExists =3D 0 Set objWMIDisk =3D GetObject("winmgmts:\\" & strComputer & "\root\WMI") Set colItem =3D objWMIDisk.ExecQuery("SELECT * FROM MSFC_FCAdapterHBAAttri= butes") HBAExists =3D colItem.Count if Err.Number =3D 0 then For Each objItem in colItem =20 Result =3D Result & "NodeWWN: " & WWNToString(objItem.NodeWWN) & vbCr= Lf Result =3D Result & "Active: " & objItem.Active & vbCrLf Result =3D Result & "DriverName: " & objItem.DriverName & vbCrLf Result =3D Result & "DriverVersion: " & objItem.DriverVersion & vbCrL= f Result =3D Result & "FirmwareVersion: " & objItem.FirmwareVersion & v= bCrLf Result =3D Result & "Model: " & objItem.Model & vbCrLf Result =3D Result & "ModelDescription: " & objItem.ModelDescription &= vbCrLf Result =3D Result & "------------------------------------------------= -" & vbCrLf Result =3D Result & QueryHBAScsiID(StrComputer) Result =3D Result & "------------------------------------------------= -" & vbCrLf Next else Err.Clear Result =3D "No HBA was found in the system." end if =20 QueryHBA =3D Result End function ' function that queries HBA SCSI ID function QueryHBAScsiID(StrComputer) 'On Error Resume Next =20 Dim objWMIDisk, colItem, objItem Dim Result : Result =3D "" Dim HBAExists : HBAExists =3D 0 Set objWMIDisk =3D GetObject("winmgmts:\\" & strComputer & "\root\WMI") Set colItem =3D objWMIDisk.ExecQuery("SELECT * FROM HBAScsiID") =20 WScript.Echo "Attempting to get 'HBA SCSI ID' info." HBAExists =3D colItem.Count if Err.Number =3D 0 then For Each objItem in colItem Result =3D Result & "ScsiBusNumber: " & objItem.ScsiBusNumber & vbCrL= f Result =3D Result & "ScsiTargetNumber: " & objItem.ScsiTargetNumber &= vbCrLf Result =3D Result & "ScsiOSLun: " & objItem.ScsiOSLun & vbCrLf Result =3D Result & "OSDeviceName: " & objItem.OSDeviceName & vbCrLf Result =3D Result & "------------------------------------------------= -" & vbCrLf Next else Err.Clear Result =3D "No 'HBA SCSI ID' was found in the system." end if =20 QueryHBAScsiID =3D Result End function ' To format WWN function WWNToString(ArrayWWN) WWNToString =3D Hex0(ArrayWWN(0)) for i =3D 1 to 7 WWNToString =3D WWNToString & ":" & Hex0(ArrayWWN(i)) next end function function Hex0(n) Hex0 =3D Hex(n) if (n < &h10) then Hex0 =3D "0" & Hex0 end function =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Thanks, Cesar