Advertisement

05.01.2008 at 01:26AM PDT, ID: 23367889
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Output information from vbscript to a text file?

Asked by mariotabone in VB Script

Tags:

I have the following vb script to get the users logged on to on a domain and i will like to get the output of this information saved to a text file. How can this be done?
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
On Error Resume next
strComputer=WScript.Arguments.Item(0)
On Error Goto 0
If strComputer="" Then 
' No specific computer was specified, proceed to query all computers in domain
Else
strPingStatus = PingStatus(strComputer)
If strPingStatus = "Success" Then
 QPO 'Run Query Process Owner function
 Else
 WScript.Echo strComputer & ",Failed ping with: " & strPingStatus
End If
WScript.quit    
End If
 
 
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
   "Select Name, Location from 'LDAP://DC=TABONE,DC=COM' " _
       & "Where objectClass='computer'"  
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
   strComputer = objRecordSet.Fields("Name").Value
   objRecordSet.MoveNext
 
If obsoliteness(strComputer) =0 Then
 
strPingStatus = PingStatus(strComputer)
If strPingStatus = "Success" Then
    QPO 'Run Query Process Owner function
Else
    WScript.Echo strComputer & ",Failed ping with: " & strPingStatus &","&time
End If
 
Else
WScript.Echo strComputer & ",Identified as an obsolite machine account,"&time
End If
Loop
WScript.Quit
 
 
 
function obsoliteness(var)
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Pattern = "(^XC00)|(^RC00)|(^QC00)|(^PC00)|(^OC00)|(^JC00)|(^HC00)|(^FC00)|(^EC00)|(^DC00)|(^CC)|(^C00)"
obsoliteness = myRegExp.test(var)
end function
 
 
Function QPO 
On Error Resume next   
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
   ("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each objProcess in colProcessList
   objProcess.GetOwner strUserName, strUserDomain 
   Wscript.Echo strComputer &",Is logged into by "&strUserDomain & "\" & strUserName &","&time
Next
End Function
 
 
Function PingStatus(strComputer)
   On Error Resume Next
   strWorkstation = "."
   Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strWorkstation & "\root\cimv2")
   Set colPings = objWMIService.ExecQuery _
     ("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer & "'")
   For Each objPing in colPings
       Select Case objPing.StatusCode
           Case 0 PingStatus = "Success"
           Case 11001 PingStatus = "Status code 11001 - Buffer Too Small"
           Case 11002 PingStatus = "Status code 11002 - Destination Net Unreachable"
           Case 11003 PingStatus = "Status code 11003 - Destination Host Unreachable"
           Case 11004 PingStatus = _
             "Status code 11004 - Destination Protocol Unreachable"
           Case 11005 PingStatus = "Status code 11005 - Destination Port Unreachable"
           Case 11006 PingStatus = "Status code 11006 - No Resources"
           Case 11007 PingStatus = "Status code 11007 - Bad Option"
           Case 11008 PingStatus = "Status code 11008 - Hardware Error"
           Case 11009 PingStatus = "Status code 11009 - Packet Too Big"
           Case 11010 PingStatus = "Status code 11010 - Request Timed Out"
           Case 11011 PingStatus = "Status code 11011 - Bad Request"
           Case 11012 PingStatus = "Status code 11012 - Bad Route"
           Case 11013 PingStatus = "Status code 11013 - TimeToLive Expired Transit"
           Case 11014 PingStatus = _
             "Status code 11014 - TimeToLive Expired Reassembly"
           Case 11015 PingStatus = "Status code 11015 - Parameter Problem"
           Case 11016 PingStatus = "Status code 11016 - Source Quench"
           Case 11017 PingStatus = "Status code 11017 - Option Too Big"
           Case 11018 PingStatus = "Status code 11018 - Bad Destination"
           Case 11032 PingStatus = "Status code 11032 - Negotiating IPSEC"
           Case 11050 PingStatus = "Status code 11050 - General Failure"
           Case Else PingStatus = "Status code " & objPing.StatusCode & _
              " - Unable to determine cause of failure."
       End Select
   Next
on error goto 0
End Function
[+][-]05.01.2008 at 06:06AM PDT, ID: 21478156

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Tags: VBScript
Sign Up Now!
Solution Provided By: PocketProtector
Participating Experts: 2
Solution Grade: B
 
 
[+][-]05.01.2008 at 08:03AM PDT, ID: 21479280

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 08:24AM PDT, ID: 21479473

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 10:46AM PDT, ID: 21480841

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.01.2008 at 11:26AM PDT, ID: 21481210

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 02:36AM PDT, ID: 21485441

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 07:59AM PDT, ID: 21487185

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 08:44AM PDT, ID: 21487577

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628