Skip to content

Instantly share code, notes, and snippets.

@sub314xxl
Created December 14, 2017 19:53
Show Gist options
  • Save sub314xxl/d9542ca24246699753d21d79134a6d6f to your computer and use it in GitHub Desktop.
Save sub314xxl/d9542ca24246699753d21d79134a6d6f to your computer and use it in GitHub Desktop.
$description = "Network Name"
$staticIp = ""
$subnetMask = ""
$gateway = ""
$adapter = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object { $_.Description -match $description}
$adapter | Invoke-CimMethod -Name EnableStatic -Arguments @{ IPAddress = $staticIp; SubnetMask = $subnetMask }
$adapter | Invoke-CimMethod -Name SetGateways -Arguments @{ DefaultIPGateway = $gateway; GatewayCostMetric = [UInt16] 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment