Dynamic IP <=> static IP script


i'm batch file girl trying modernize! need wsh script in form of clients can execute on machines , minimum of hassle , without me requiring special privileges. script should take existing ip address, subnet mask , default gateway of ethernet adapter , set these static parameters (and reverse set back). know how set parameters manually on command line using netsh command i.e.

netsh.exe interface ip set address {interface} static {ip} {sub} {def} 1

suspect done automatically wsh script. clients either xp/vista/windows 7. best way accomplish this?

1) powershell:

http://social.technet.microsoft.com/forums/en-us/winserverpowershell/thread/50f07ed6-c076-4920-a7f2-3a0f5292a177

2) vbscript 

strcomputer = "." set objwmiservice = getobject("winmgmts:" _  & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")  set colnetadapters = objwmiservice.execquery _  ("select * win32_networkadapterconfiguration ipenabled=true , dhcpenabled=true")   each objnetadapter in colnetadapters 	stripaddress = array(objnetadapter.ipaddress(0)) 	strsubnetmask = array(objnetadapter.ipsubnet(0)) 	strgateway = array(objnetadapter.defaultipgateway(0)) 	strgatewaymetric = array(1) 	errenable = objnetadapter.enablestatic(stripaddress, strsubnetmask)  	errgateways = objnetadapter.setgateways(strgateway, strgatewaymetric)  	if errenable = 0   	wscript.echo "the ip address has been changed."  	else   		wscript.echo "the ip address not changed."  	end if next   

 

the best practice use dhcp.but assign script computers may use:

1) logon script.

2) run user on local computer(user member of network configuration operators).

3) run script on operator machine , apply client computer:

powershell - get-wmiobject win32_networkadapterconfiguration -computername 192.168.0.149 (change)  vbscript - strcomputer = "." (change)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group