Set-NetIPAddress cmdlet

Spread the words

The Set-NetIPAddress cmdlet modifies IP address configuration properties of an existing IP address.

Parameters:

  • AddressFamily (IPv4, IPv6)

The cmdlet modifies the IP address configuration that matches the families.

  • AddressState (Invalid, Tentative, Duplicate, Deprecated, Preferred)
  • CimSession

This parameter runs the cmdlet in a remote session or on a remote computer.

  • IncludeAllCompartments

The cmdlet includes addresses from all configured network compartments.

  • InterfaceAlias

The cmdlet modifies IP addresses that match the aliases.

  • InterfaceIndex

The cmdlet modifies IP addresses that match the indexes.

  • IPAddress

The cmdlet specifies the IP address.

  • PassThru

The cmdlet returns an object representing the item with which you are working.

  • PolicyStore (ActiveStore, PersistentStore)
  • PreferredLifetime
  • PrefixLength

This parameter defines the local subnet size, and is also known as a subnet mask.

  • PrefixOrigine
  • SkipAsSource

This parameter identifies the primary IP address for outgoing traffic in a multiple IP address scenario.

  • SuffixOrigin (Manuel, WellKnown, DHCP, Link, Random)
  • ThrottleLimit
  • Type (Unicast, Anycast)
  • ValidLifetime
  • Confirm

This parameter prompts you for confirmation before running the cmdlet.

  • WhatIf

It shows what would happen if the cmdlet runs.

Inputs:

The input type is the type of the objects that you can pipe to the cmdlet.

Microsoft.Management.Infrastructure.CimInstance#root\StandardCimv2\MSFT_NetIPAddress

Examples:

 This command adds the IP address 192.168.0.1 to the interface located at index 12.

Set-NetIPAddress –InterfaceIndex 12 –IPAddress 192.168.0.1

With netmask 255.255.255.0

Set-NetIPAddress –InterfaceIndex 12 –IPAddress 192.168.0.1 –PrefixLength 24

 The first command creates a new TimeSpan object of one day, and stores it in the variable named $Timesp.

The second command then uses the TimeSpan object to set the preferred lifetime of the IP address located at interface 12 to one day.

$Timesp = ( New-TimeSpan –Days 1 )

Set-NetIPAddress –InterfaceIndex 12 –IPAddress 192.168.0.1 –PreferredLifetime $Timesp

Be the first to comment on "Set-NetIPAddress cmdlet"

Leave a comment

Your email address will not be published.


*