This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-NetworkAdapterIPAddress

Synopsis

Sets the IP address of a network adapter on a local or remote computer.

Syntax

  • Set-NetworkAdapterIPAddress [-Name] [-IPAddress] [-Subnet] [-ComputerName] [-Credential]
  • Set-NetworkAdapterIPAddress [-MACAddress] [-IPAddress] [-Subnet] [-ComputerName] [-Credential]

Description

The Set-NetworkAdapterIPAddress cmdlet is used to set the static IP address of a network adapter on a local or remote computer. Adapters can be identified by name or MAC address.

Parameters

  • Name The name of the network adapter to configure. This parameter cannot be used when the MACAddress parameter has been specified.
  • MACAddress The MAC address of the network adapter to configure. This parameter cannot be used when the name parameter has been specified.
  • IPAddress The IP address to assign to the network adapter.
  • Subnet The subnet mask for the supplied IP address.
  • ComputerName The computer against which to run the cmdlet. By default this cmdlet will be populated with the name of the local computer.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.

Inputs

Set-NetworkAdapterIPAddress accepts the output of Get-NetworkAdapter as an input object. The Name, MACAddress and ComputerName parameters each accept pipeline input by property name.

Outputs

Set-NetworkAdapterIPAddress makes changes directly to Windows and does not output any Powershell objects.

Notes

The Set-NetworkAdapterIPAddress cmdlet requires that the Remote Registry and RPC services are started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will set the adapter "Local Area Connection" on the local computer to static IP address 192.168.0.44:

C:\PS>Set-NetworkAdapterIPAddress "Local Area Connection" -IPAddress 192.168.0.44 -Subnet 255.255.255.0

Example 2

This command will set the adapter "Local Area Connection" on the remote computer PC01 to static IP address 192.168.0.44:

C:\PS>Set-NetworkAdapterIPAddress "Local Area Connection" -IPAddress 192.168.0.44 -Subnet 255.255.255.0 -Computer PC01

Example 3

Set-NetworkAdapterIPAddress also works in conjunction with the Get-NetworkAdapter cmdlet. This command will find the network adapter with address 192.168.0.22 on the local computer and amend that address to 192.168.0.44:

C:\PS>Get-NetworkAdapter -IPAddress 192.168.0.22 | Set-NetworkAdapterIPAddress 192.168.0.44 255.255.255.0