#141303 - 2005-06-08 08:05 PM
Static IP TO DHCP conversion script
|
tmclean
Fresh Scripter
Registered: 2001-01-26
Posts: 18
Loc: Sault Ste. Marie Ontario
|
At one time, I've seen a script on this forum to perform a conversion from statically IP assigned workstations to DHCP. I cannot find it now. Has anyone else seen it or is it still around. Thx.
|
|
Top
|
|
|
|
#141309 - 2005-06-10 02:19 AM
Re: Static IP TO DHCP conversion script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
$strComputer = "." $objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2") if $objWMIService $colNetAdapters = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each $objNetAdapter In $colNetAdapters $errEnable = $objNetAdapter.EnableDHCP() ? iif($errEnable=0,"Success","Error Setting DHCP") Next else ? "error getting WMI" endif
|
|
Top
|
|
|
|
#141310 - 2005-06-10 04:07 AM
Re: Static IP TO DHCP conversion script
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4572
Loc: USA
|
Good catch Les... updated...
Code:
function EnableDHCP(optional $remotepc) dim $objWMIService, $colitems, $objnetadapter,$ $enableDHCP=1 if $remotepc="" $remotepc="." endif $objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2") if @error exit @error else $colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1") For Each $objNetAdapter In $colItems $=$objNetAdapter.EnableDHCP $=$objNetAdapter.SetDNSServerSearchOrder $=$objNetAdapter.SetDNSDomain $=$objNetAdapter.SetWINSServer("","") $enabledhcp=0 Next endif endfunction
Edited by Allen (2005-06-11 11:04 PM)
|
|
Top
|
|
|
|
#141312 - 2005-06-29 01:52 AM
Re: Static IP TO DHCP conversion script
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4572
Loc: USA
|
|
|
Top
|
|
|
|
#141314 - 2005-06-29 06:39 PM
Re: Static IP TO DHCP conversion script
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
ROFL... Well this article actually goes over this stuff fairly well. Not 100% complete, but not too bad.
Quote:
This paper discusses scripting techniques and shows scripting examples that enable system administrators to automate many common tasks involved in managing TCP/IP network clients.
Automating TCP/IP Networking on Clients Online version
Automating TCP/IP Networking on Clients - Online version
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|