Link to home
Start Free TrialLog in
Avatar of PAdocIT
PAdocITFlag for United States of America

asked on

VBScript help

I would like to modify the following VB script to check chassis type and if the chassis type is a laptop I would like the script to end. If else I want the script to continue on and add the DNS. Can anyone help me out or point me in the right direction, preferably the former as I really no nothing about VB. :)

Thanks,
Mike

	strComputer = "."
	'wscript.echo strComputer
	'strComputer = InputBox("Enter the Machine Name you want to modify")
	On Error Resume Next
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colNetCards = objWMIService.ExecQuery _
	("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
	'change arrDNSServers to reflect values for your environment
	For Each objNetCard in colNetCards
		arrDNSServers = Array("0.0.0.1","0.0.0.2","0.0.0.3")
		objNetCard.SetDNSServerSearchOrder(arrDNSServers)
	Next

	If Err.Number <> 0 Then 
		'wscript.echo err.number
		'If err.number =  462 then
			'strStatus = "Error-COULD NOT CONNECT," &strComputer
		'ElseIf err.number = 451 then
			'strStatus = "Error-ACCESS DENIED," &strComputer		
		'Else
			strStatus = "Error," & strComputer
		'End If
	Else
		strStatus = "Success," & strComputer
	End If
	w.writeline strStatus
	Err.Clear
	On Error Goto 0

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PAdocIT

ASKER

Thanks I will try it out. I'm not really sure about log file creation as I didn't create the script. The script is run as part of our site policy in GP. Our AD/GPO guy added this script (don't think he wrote it either) to auto set DNS based on the machine's network info. This was done to help avoid user input errors or forgetting to set DNS all together during machine setup. Not much of an issue since switching to SCCM OSD but he refuses to get rid of the script. The problem I have now is when we deploy laptops they get these DNS addresses embedded in them and users can't resolve domain names when connected mobile broadband or wifi at home. Big problem since our VPN is web based. If only our networking guy would go to DHCP this would all be moot. Ahhh government. :)

Anyway a little background since my original post was a bit vague.
OK, don't worry about the log file then.  Remove this line
w.writeline strStatus

Wow, no DHCP...that must be a nightmare....I hope this script helps.

Rob.
Avatar of PAdocIT

ASKER

Thanks Rob. Worked like a charm.
Very good.  Thanks for the grade.

Regards,

Rob.