Win 7 clients,
Need to populate alternate IP with current DHCP assignment (I believe everything else will be static).
It appears that PowerShell is the only way to get at the alternate IP config variables. We are wrestling with a TechRepublic PS module that could be the modified.

I used to do a lot more of this kind of stuff, and loved this site. But I'm rusty as hell. Anyone got any pointers, thoughts or suggestions on the easiest way to remotely update these variables across a mid-sized enterprise?

Thanks for anything short of go away. :)

Dani AI

Generated

Quick, pragmatic plan for (and thanks to for pointing toward PowerShell): on Windows 7 you can automate this, but pick the right technique and test first. Windows 7 doesn’t have the modern NetTCPIP cmdlets, so you must use WMI, netsh, or the IP Helper API — and each behaves differently:

  • WMI’s EnableStatic sets static addresses (it turns DHCP off for that adapter). See the EnableStatic docs. (If you convert a NIC to static you must reapply gateway/DNS with SetGateways / SetDNSServerSearchOrder.) EnableStatic docs.
  • Microsoft documented a Windows 7/2008 R2 problem where applications using EnableStatic may fail on those OSes — so test carefully. MS support note.

Two realistic deployment patterns

  1. Temporary / non‑persistent alias: use the IP Helper API (AddIPAddress) to add the DHCP address as an extra address for the session. That doesn’t survive reboot (so safe if you just need a temporary alternate address). AddIPAddress (iphlpapi) docs.

  2. Persistent alias on Win7: you must convert the adapter to static and set every IP you want using EnableStatic (then reapply gateways/DNS). Netsh’s add address on older Windows will also disable DHCP — it does not provide the DHCP+static coexistence that Windows 10 (1703+) later added via dhcpstaticipcoexistence. Plan for that limitation. netsh interface docs — and background on coexistence added in newer Windows (for context) is here: SuperUser discussion.

Recommended safe rollout

  • Don’t enable PSRemoting broadly just to push changes; a GPO computer startup script or your deployment tool (SCCM/PDQ) that runs locally (SYSTEM) is simpler and safer. If you do use WinRM, enable it deliberately (Enable-PSRemoting) and account for firewall/WinRM policy. Enable-PSRemoting docs.
  • Always: (a) run on a pilot group, (b) capture current IP/gateway/DNS to a central log before change, (c) provide a one‑button rollback (call EnableDHCP or restore saved settings), and (d) monitor.

Example GPO startup PowerShell (concept — test and adapt before mass run):

# Run elevated (GPO Computer Startup). Adjust $LogShare before use.
$LogShare = '\\fileserver\logs\nic-alt-ip.log'
function Log { param($m) "$((Get-Date).ToString('s')) - $m" | Out-File -FilePath $LogShare -Append }

$nic = Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled = True AND DHCPEnabled = True" | Select -First 1
if (-not $nic) { Log 'No DHCP-enabled NIC found'; exit 0 }

$dhcpIP = ($nic.IPAddress | Where { $_ -match '^\d{1,3}(\.\d{1,3}){3}$' })[0]
$dhcpMask = ($nic.IPSubnet | Where { $_ -match '^\d{1,3}(\.\d{1,3}){3}$' })[0]
$existing = @()            # if adapter already static, populate from $nic.IPAddress
$newIPs = ($existing + $dhcpIP) | Select-Object -Unique
$masks  = foreach ($ip in $newIPs) { $dhcpMask }

# Preserve gateway/DNS
$gw  = $nic.DefaultIPGateway
$dns = $nic.DNSServerSearchOrder

$ret = $nic.EnableStatic($newIPs, $masks)
if ($ret -eq 0 -or $ret -eq 1) {
  if ($gw)  { $nic.SetGateways($gw, @(1)) }
  if ($dns) { $nic.SetDNSServerSearchOrder($dns) }
  Log "EnableStatic succeeded ($ret): $($newIPs -join ',')"
} else {
  Log "EnableStatic failed code $ret"
}

Final cautions: test on representative hardware, maintain a documented rollback (EnableDHCP or restore the saved settings), and prefer a one‑time startup script that removes itself after success if you must avoid long‑term changes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.