Skip to main content
Question

Need help with VB script for an extension attribute

  • November 25, 2011
  • 1 reply
  • 0 views

Forum|alt.badge.img+6

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!

1 reply

leslie_h
Forum|alt.badge.img+14
  • Employee
  • 100 replies
  • November 27, 2011

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>"
Wscript.Quit
End If

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

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings