Advertisement

07.08.2008 at 05:47AM PDT, ID: 23546376
[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!

9.4

cli arguments to run cerain sections of vbs/wmi script

Asked by richrumble in VB Script, Miscellaneous Software, Microsoft Operating Systems

Tags: , ,

I'd like to have a very large script, able to be run in sections if a certain argument is given. Currently the script accepts ip/dns, user, pass as arguments, /s: /u: /p: respectively, and I'd like it to run only certain sections of the script if another argument is given... /c:cpu hd mem
which would run the cpu section, the harddrive and memory section of the attached script.
The current sections are, and if it's possible I'd like the args to be...
harddrive arg= hd
login arg= lgn
bios arg= bios
video arg= vid
memory arg= mem
network arg=nic
processor arg = cpu
hardware arg= hw
If no /c: is given, run the entire script.
Again, this script currently runs with: cscript inventory.vbs /s:1.2.3.4 /u:admin /p:password
and I'd like it to run with cscript inventory.vbs /s:1.2.3.4 /u:admin /p:password /c:cpu hd mem (for example)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:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
If Wscript.Arguments.Named("u") <> "" And Wscript.Arguments.Named("p") <> "" Then
    boolAlternate = True
    strUser = WScript.Arguments.Named("u")
    strPassword = WScript.Arguments.Named("p")
'    WScript.Echo "Using alternate credentials..."
Else
        boolAlternate = False
'        WScript.Echo "Using current credentials..."
End If
If WScript.Arguments.Named("s") = "" Then
        arrComputers = Array(".")
Else
    arrComputers = Split(WScript.Arguments.Named("s"), ",")
End If
 
Const WbemAuthenticationLevelPktPrivacy = 6
On Error Resume Next
 
For Each strComputer In arrComputers
        
        If boolAlternate = True Then
                strNamespace = "root\cimv2"
                Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
                Set objWMIService = objwbemLocator.ConnectServer _
                    (strComputer, strNamespace, strUser, strPassword)
                objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
        Else
                Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        End If  
'	Get Harddrive(s) Info
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Description = 'Local Fixed Disk'")
	For Each objItem in colItems
	    WScript.Echo  objItem.VolumeName
	    WScript.Echo  objItem.Description
	    WScript.Echo  objItem.Name
	    WScript.Echo  objItem.DeviceID
	    WScript.Echo  objItem.Size
	    Wscript.Echo  objItem.FreeSpace
	    Wscript.Echo  objItem.FileSystem
	    Wscript.Echo  objItem.VolumeSerialNumber
 
	Next
'	Get Local Login Information
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem in colItems
	    Wscript.Echo  objItem.Caption
	    Wscript.Echo  objItem.CurrentTimeZone
	    Wscript.Echo  objItem.Description
	    Wscript.Echo  objItem.Domain
	    Wscript.Echo  objItem.Manufacturer
	    Wscript.Echo  objItem.Model
	    Wscript.Echo  objItem.Name
	    Wscript.Echo  objItem.UserName
	Next
'	Get Bios info, includng Dell Tag, Bios Revision and Manufacturer
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
	For Each objItem in colItems
	    Wscript.Echo  objItem.BIOSVersion
	    Wscript.Echo  objItem.BuildNumber
	    Wscript.Echo  objItem.Description
	    Wscript.Echo  objItem.Manufacturer
	    Wscript.Echo  objItem.Name
	    Wscript.Echo  objItem.SerialNumber
	    Wscript.Echo  objItem.Status
	    Wscript.Echo  objItem.Version
	Next
	
'	Get Screen Resolution, Refreash and Video Card info
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayControllerConfiguration",,48)
	For Each objItem in colItems
	    Wscript.Echo  objItem.Description
	    Wscript.Echo  objItem.Name
	    Wscript.Echo  objItem.RefreshRate
	    Wscript.Echo  objItem.VideoMode
	Next
 
'	Get Memory Information
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalMemoryConfiguration",,48)
	For Each objItem in colItems
	    Wscript.Echo  objItem.AvailableVirtualMemory
	    Wscript.Echo  objItem.TotalPageFileSpace
	    Wscript.Echo  objItem.TotalPhysicalMemory
	    Wscript.Echo  objItem.TotalVirtualMemory
	Next
 
'	Get NIC information
Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration " & "Where IPEnabled = True")
	For Each objItem in colItems
	    Wscript.Echo  objItem.Caption
	    strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
	    WScript.Echo  strDefaultIPGateway
	    For Each objAddress in objItem.IPAddress
	        Wscript.Echo  objAddress
	        Wscript.Echo  objItem.MACAddress
	        Wscript.Echo  objItem.WINSPrimaryServer
	        Wscript.Echo  objItem.WINSSecondaryServer
	    Next
	Next
 
'	Get CPU Information
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
	For Each objItem in colItems
	    Wscript.Echo  objItem.DeviceID
	    Wscript.Echo  objItem.Caption
	    Wscript.Echo  objItem.CurrentClockSpeed
	    Wscript.Echo  objItem.Description
	    Wscript.Echo  objItem.Family
	    Wscript.Echo  objItem.LoadPercentage
	    Wscript.Echo  objItem.Manufacturer
	    Wscript.Echo  objItem.Name
	    Wscript.Echo  objItem.Status
	    Wscript.Echo  objItem.Version
	Next
 
'	Show non-functioning Devices (yellow exclamation point, Or red circle)
 Set colItems = objWMIService.ExecQuery _
   ("Select * from Win32_PNPEntity Where ConfigManagerErrorCode <> 0")
	For Each objItem in colItems
	   Wscript.Echo  objItem.Name
	   Wscript.Echo  objItem.Description
	   Wscript.Echo  objItem.DeviceID
	   Wscript.Echo  objItem.Manufacturer
	Next
Next
[+][-]07.08.2008 at 09:53AM PDT, ID: 21955725

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.

 
[+][-]07.08.2008 at 10:57AM PDT, ID: 21956288

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.08.2008 at 11:12AM PDT, ID: 21956447

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.

 
[+][-]07.08.2008 at 11:15AM PDT, ID: 21956470

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.

 
[+][-]07.08.2008 at 02:26PM PDT, ID: 21958422

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

Zones: VB Script, Miscellaneous Software, Microsoft Operating Systems
Tags: microsoft wmi vbscript vbs, vbs wmi, wmi vbs vbscript arguments
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.09.2008 at 09:47AM PDT, ID: 21965716

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.09.2008 at 12:19PM PDT, ID: 21967276

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.09.2008 at 02:09PM PDT, ID: 21968407

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.

 
[+][-]07.09.2008 at 04:13PM PDT, ID: 21969200

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.09.2008 at 04:31PM PDT, ID: 21969290

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