Activer le DHCP sur un poste client via vbs

scripting_vbs.gifRemplacer le point (« . ») par l’adresse ip de la machine a basculer en DHCP

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")

Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each objNetAdapter In colNetAdapters
    'Reset IP Address and Default Gateway to DHCP
    errEnable = objNetAdapter.EnableDHCP()
    'Reset DNS Server list to DHCP
    arrDNSServers = Array()
    objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
    'Reset DNS Server Domain to DHCP
    strDNSDomain = ""
    objNetAdapter.SetDNSDomain strDNSDomain
    'Reset WINS Server list to DHCP
    strPrimaryServer = ""
    strSecondaryServer = ""
    objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer
    'Reset DNS Server Suffix list
    Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
    Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
    arrDNSSuffixes = Array("", "")
    objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)
Next

Pas de commentaire »

No comments yet.

Leave a comment