Ron Shorts
asked on
vbscript, email results
I have a script that saige helped me put together for file shares. The script excludes all default file shares.
I want to have this email the results via smtp, the name of the computer, service name and path location. Script below. Thanks in advance.
Dim strComputer, strResult
Dim exclusions
If Trim(strComputer) = "" Then strComputer = "."
exclusions = Array("Apps$", "sys$")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery("S ELECT * FROM Win32_Share WHERE NOT Type=2147483648 AND NOT Type=2147483649 AND NOT Type=2147483650 AND NOT Type=2147483651")
Set objExcel = CreateObject("Excel.Applic ation")
objExcel.Workbooks.Add
For each objShare in colShares
If UBound(Filter(exclusions, objShare.Name, True, 1)) < 0 Then
strResult = strResult + "AllowMaximum: " & vbTab & objShare.AllowMaximum & vbcrlf &_
"Caption: " & vbTab & objShare.Caption & vbcrlf &_
"MaximumAllowed: " & vbTab & objShare.MaximumAllowed & vbcrlf &_
"Name: " & vbTab & objShare.Name & vbcrlf &_
"Path: " & vbTab & objShare.Path & vbcrlf &_
"Type: " & vbTab & objShare.Type & vbcrlf & vbcrlf
End If
Next
wscript.echo "Shares on computer: " & strComputer & vbcrlf & vbcrlf & strResult
'wscript.echo "Done"
I want to have this email the results via smtp, the name of the computer, service name and path location. Script below. Thanks in advance.
Dim strComputer, strResult
Dim exclusions
If Trim(strComputer) = "" Then strComputer = "."
exclusions = Array("Apps$", "sys$")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colShares = objWMIService.ExecQuery("S
Set objExcel = CreateObject("Excel.Applic
objExcel.Workbooks.Add
For each objShare in colShares
If UBound(Filter(exclusions, objShare.Name, True, 1)) < 0 Then
strResult = strResult + "AllowMaximum: " & vbTab & objShare.AllowMaximum & vbcrlf &_
"Caption: " & vbTab & objShare.Caption & vbcrlf &_
"MaximumAllowed: " & vbTab & objShare.MaximumAllowed & vbcrlf &_
"Name: " & vbTab & objShare.Name & vbcrlf &_
"Path: " & vbTab & objShare.Path & vbcrlf &_
"Type: " & vbTab & objShare.Type & vbcrlf & vbcrlf
End If
Next
wscript.echo "Shares on computer: " & strComputer & vbcrlf & vbcrlf & strResult
'wscript.echo "Done"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER