New-NetIPAddress
New-NetIPAddress
Creates and configures an IP address.
Syntax
Parameter Set: ByInterfaceAlias
New-NetIPAddress [-IPAddress] <String> -InterfaceAlias <String> [-AddressFamily <AddressFamily> {IPv4 | IPv6} ] [-CimSession <CimSession[]> ] [-DefaultGateway <String> ] [-PolicyStore <String> ] [-PreferredLifetime <TimeSpan> ] [-PrefixLength <Byte> ] [-SkipAsSource <Boolean> ] [-ThrottleLimit <Int32> ] [-Type <Type> {Unicast | Anycast} ] [-ValidLifetime <TimeSpan> ] [-Confirm] [-WhatIf] [ <CommonParameters>] [ <WorkflowParameters>]
Parameter Set: ByInterfaceIndex
New-NetIPAddress [-IPAddress] <String> -InterfaceIndex <UInt32> [-AddressFamily <AddressFamily> {IPv4 | IPv6} ] [-CimSession <CimSession[]> ] [-DefaultGateway <String> ] [-PolicyStore <String> ] [-PreferredLifetime <TimeSpan> ] [-PrefixLength <Byte> ] [-SkipAsSource <Boolean> ] [-ThrottleLimit <Int32> ] [-Type <Type> {Unicast | Anycast} ] [-ValidLifetime <TimeSpan> ] [-Confirm] [-WhatIf] [ <CommonParameters>] [ <WorkflowParameters>]
Detaillierte Beschreibung
The New-NetIPAddress cmdlet creates and configures an IP address. To create a specific IP address object, specify either an IPv4 address or an IPv6 address, and an interface index or interface alias. We recommend that you define the prefix length, also known as a subnet mask, and a default gateway.
If you run this cmdlet to add an IP address to an interface on which DHCP is already enabled, then DHCP is automatically disabled.
Parameter
-AddressFamily<AddressFamily>
Specifies an IP address family. The cmdlet creates an IP address for the family. If you do not specify this parameter, the property is automatically generated. Die zulässigen Werte für diesen Parameter sind:
-- IPv4
-- IPv6
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-CimSession<CimSession[]>
Das Cmdlet wird in einer Remotesitzung oder auf einem Remotecomputer ausgeführt. Geben Sie einen Computernamen oder ein Sitzungsobjekt ein, wie z. B. die Ausgabe eines New-CimSession oder Get-CimSession-Cmdlets. Der Standardwert ist die aktuelle Sitzung auf dem lokalen Computer.
Aliase |
Session |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-DefaultGateway<String>
Specifies the IPv4 address or IPv6 address of the default gateway for the host. Default gateways provide a default route for TCP/IP hosts to use when communicating with other hosts on remote networks.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-InterfaceAlias<String>
Specifies an alias of a network interface. The cmdlet creates an IP address for the alias.
Aliase |
ifAlias |
Erforderlich? |
true |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
True (ByPropertyName) |
Platzhalterzeichen akzeptieren? |
false |
-InterfaceIndex<UInt32>
Specifies an index of a network interface. The cmdlet creates an IP address for the index.
Aliase |
ifIndex |
Erforderlich? |
true |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
True (ByPropertyName) |
Platzhalterzeichen akzeptieren? |
false |
-IPAddress<String>
Specifies the IPv4 or IPv6 address to create.
Aliase |
LocalAddress |
Erforderlich? |
true |
Position? |
1 |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
True (ByPropertyName) |
Platzhalterzeichen akzeptieren? |
false |
-PolicyStore<String>
Specifies a PolicyStore value. Die zulässigen Werte für diesen Parameter sind:
-- ActiveStore. The IP address information is valid.
-- PersistentStore. The computer saves IP address information across restarts. When the computer restarts, it copies the saved settings to the ActiveStore.
The default value is ActiveStore. Specify ActiveStore only.
If you do not specify this parameter, the default entries are created in both the ActiveStore and the PersistentStore.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-PreferredLifetime<TimeSpan>
Specifies a preferred lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-PrefixLength<Byte>
Specifies a prefix length. This parameter defines the local subnet size, and is also known as a subnet mask.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-SkipAsSource<Boolean>
Indicates whether an address is a primary IP address. This parameter identifies the primary IP address for outgoing traffic in a multiple IP address scenario. If this parameter is set to True, the addresses are not used for outgoing traffic and are not registered in DNS.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-ThrottleLimit<Int32>
Gibt die maximale Anzahl gleichzeitiger Vorgänge an, die zum Ausführen des Cmdlets hergestellt werden können. Wenn dieser Parameter ausgelassen wird oder der Wert 0
eingegeben wird, berechnet Windows PowerShell ® einen optimalen Drosselungsgrenzwert für das Cmdlet basierend auf der Anzahl der CIM-Cmdlets, die auf dem Computer ausgeführt werden. Der Grenzwert gilt nur für das aktuelle Cmdlet, nicht für die Sitzung oder den Computer.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-Type<Type>
Specifies an IP address type. Die zulässigen Werte für diesen Parameter sind:
-- Unicast
-- Anycast
The default value is Unicast.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-ValidLifetime<TimeSpan>
Specifies a valid lifetime value, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Aliase |
none |
Erforderlich? |
false |
Position? |
named |
Standardwert |
none |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-Confirm
Fordert Sie vor der Ausführung des Cmdlet zum Bestätigen auf.
Erforderlich? |
false |
Position? |
named |
Standardwert |
false |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
-WhatIf
Zeit, was passieren würde, wenn das Cmdlet ausgeführt wird. Das Cmdlet wird nicht ausgeführt.
Erforderlich? |
false |
Position? |
named |
Standardwert |
false |
Pipelineeingaben akzeptieren? |
false |
Platzhalterzeichen akzeptieren? |
false |
<CommonParameters>
Dieses Cmdlet unterstützt die allgemeinen Parameter: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer und -OutVariable. Weitere Informationen finden Sie unter about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
<WorkflowParameters>
Eingaben
Der Eingabetyp ist der Typ der Objekte, die Sie per Piping an das Cmdlet übergeben können.
- None
Ausgaben
Der Ausgabetyp ist der Typ der Objekte, die vom Cmdlet ausgegeben werden.
Microsoft.Management.Infrastructure.CimInstance#root\StandardCimv2\MSFT_NetIPAddress
Das
Microsoft.Management.Infrastructure.CimInstance
-Objekt ist eine Wrapperklasse, die Windows-Verwaltungsinstrumentation-Objekte (Windows Management Instrumentation, WMI) angezeigt. Der Pfad nach dem Nummernzeichen (#
) stellt den Namespace und den Klassennamen des zugrunde liegenden WMI-Objekts dar.
Beispiele
Example 1: Add an IPv4 address
The first command adds a new IPv4 address to the network interface at index 12. The PrefixLength parameter specifies the subnet mask for the IP address. In this example, the PrefixLength of 24 equals a subnet mask of 255.255.255.0. When you add an IPv4 address, the address specified for the Default Gateway must be in the same subnet as the IPv4 address that you add.
PS C:\> New-NetIPAddress –InterfaceIndex 12 –IPAddress 192.168.0.1 -PrefixLength 24 -DefaultGateway 192.168.0.5
The second command removes the IPv4 address. To remove the IPv4 address, use the Remove-NetIPAddress cmdlet.
PS C:\> Remove-NetIPAddress –IPAddress 192.168.0.1 -DefaultGateway 192.168.0.5