Need help with VB script for an extension attribute

New Contributor II

We are moving from pc based to mac. I wanted to use recon to gather info from the pc to make the transition easier. I can get a list of printers they have installed on the pc. I also wanted to get a list of mapped network drives. I found a VB script that says it will do that but not sure how to word it correctly to work as a VB extension attribute.

On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")

Set colDrives = objNetwork.EnumNetworkDrives

For i = 0 to colDrives.Count-1 Step 2

I know it needs a Wscript.Echo line at the value passed but not sure how.

Hope someone out there can help!


Contributor II

See if the following does the trick:

Option Explicit
Dim objNetwork, objDrives, DriveNum, listDrives

On error resume next

Set objNetwork = CreateObject("WScript.Network")
Set objDrives = objNetwork.EnumNetworkDrives

'check if there are no mapped drives
If objDrives.Count = 0 Then
WScript.Echo "<result>No Drives Mapped</result>"
End If

'List the mapped drives
For DriveNum = 0 to objDrives.Count -1 Step 2
listDrives = objDrives.Item(DriveNum +1) & vbCrLf & listDrives
WScript.Echo "<result>" & listDrives & "</result>"

Couple notes:
After the script is saved the '&' will be displayed as '&amp;', save it again and you'll get '&amp;amp;'... So if you makes changes after saving it once be sure to convert each occurance of '&amp;' back to '&' before saving again.
Extension attribute displayed when viewing the extension attribute under computer details lacks multiple line output, but looks fine if displayed under an advanced search.

Leslie N. Helou
Senior Systems Engineer
Bell Techlogix
8888 Keystone Crossing, Suite 1700
Indianapolis, IN 46240