Add-VMNetworkAdapterExtendedAcl

Creates an extended ACL for a virtual network adapter.

Syntax

Add-VMNetworkAdapterExtendedAcl
   [-Action] <VMNetworkAdapterExtendedAclAction>
   [-Direction] <VMNetworkAdapterExtendedAclDirection>
   [[-LocalIPAddress] <String>]
   [[-RemoteIPAddress] <String>]
   [[-LocalPort] <String>]
   [[-RemotePort] <String>]
   [[-Protocol] <String>]
   [-Weight] <Int32>
   [-Stateful <Boolean>]
   [-IdleSessionTimeout <Int32>]
   [-IsolationID <Int32>]
   [-Passthru]
   [-VMNetworkAdapterName <String>]
   [-CimSession <CimSession[]>]
   [-ComputerName <String[]>]
   [-Credential <PSCredential[]>]
   [-VMName] <String[]>
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-VMNetworkAdapterExtendedAcl
   [-Action] <VMNetworkAdapterExtendedAclAction>
   [-Direction] <VMNetworkAdapterExtendedAclDirection>
   [[-LocalIPAddress] <String>]
   [[-RemoteIPAddress] <String>]
   [[-LocalPort] <String>]
   [[-RemotePort] <String>]
   [[-Protocol] <String>]
   [-Weight] <Int32>
   [-Stateful <Boolean>]
   [-IdleSessionTimeout <Int32>]
   [-IsolationID <Int32>]
   [-Passthru]
   [-VMNetworkAdapter] <VMNetworkAdapterBase[]>
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-VMNetworkAdapterExtendedAcl
   [-Action] <VMNetworkAdapterExtendedAclAction>
   [-Direction] <VMNetworkAdapterExtendedAclDirection>
   [[-LocalIPAddress] <String>]
   [[-RemoteIPAddress] <String>]
   [[-LocalPort] <String>]
   [[-RemotePort] <String>]
   [[-Protocol] <String>]
   [-Weight] <Int32>
   [-Stateful <Boolean>]
   [-IdleSessionTimeout <Int32>]
   [-IsolationID <Int32>]
   [-Passthru]
   [-ManagementOS]
   [-VMNetworkAdapterName <String>]
   [-CimSession <CimSession[]>]
   [-ComputerName <String[]>]
   [-Credential <PSCredential[]>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Add-VMNetworkAdapterExtendedAcl
   [-Action] <VMNetworkAdapterExtendedAclAction>
   [-Direction] <VMNetworkAdapterExtendedAclDirection>
   [[-LocalIPAddress] <String>]
   [[-RemoteIPAddress] <String>]
   [[-LocalPort] <String>]
   [[-RemotePort] <String>]
   [[-Protocol] <String>]
   [-Weight] <Int32>
   [-Stateful <Boolean>]
   [-IdleSessionTimeout <Int32>]
   [-IsolationID <Int32>]
   [-Passthru]
   [-VMNetworkAdapterName <String>]
   [-VM] <VirtualMachine[]>
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Add-VMNetworkAdapterExtendedAcl cmdlet creates an extended access control list (ACL) for a virtual network adapter. The ACL allows or denies access to a virtual machine network adapter for network packets based on source IP address, destination IP address, protocol, source port, and destination port.

Examples

Example 1: Create an ACL for Remote Desktop Protocol

PS C:\> Add-VMNetworkAdapterExtendedAcl -VMName "TSQA01" -Action Allow -Direction Inbound -LocalPort "3389" -Protocol "TCP" -Weight 10 -Stateful $True

This command creates a stateful inbound ACL that allows a remote device to connect to the virtual machine on port 3389, which is the port for Remote Desktop Protocol.

Example 2: Create an ACL to initiate a connection with timeout

PS C:\> Add-VMNetworkAdapterExtendedAcl -VMName "TSQA03" -Action Allow -Direction Outbound -RemotePort "80" -Protocol "TCP" -Weight 100 -Timeout 3600 -Stateful $True

This command creates a stateful ACL that allows outbound packets to a remote device by using TCP. If there is no activity for 3600 seconds, the connection times out.

Parameters

-Action

Specifies the action for the ACL. The acceptable values for this parameter are:

  • Allow
  • Deny
Type:VMNetworkAdapterExtendedAclAction
Accepted values:Allow, Deny
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Type:CimSession[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ComputerName

Specifies an array of Hyper-V hosts. The cmdlet adds the ACL to the network adapters on the Hyper-V hosts that you specify.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Credential

Specifies one or more user accounts that have permission to perform this action. The default is the current user.

Type:PSCredential[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Direction

Specifies the direction of network traffic, from the perspective of the virtual machine, to which the ACL applies. The cmdlet adds an ACL that has the value that you specify. The acceptable values for this parameter are:

  • Inbound
  • Outbound

If you run the Get-VMNetworkAdapterExtendedAcl cmdlet, the entry that you create appears in both the inbound ACL and the outbound ACL.

Type:VMNetworkAdapterExtendedAclDirection
Accepted values:Inbound, Outbound
Position:2
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-IdleSessionTimeout

Specifies a time-out period, in seconds, for idle sessions.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IsolationID

Specifies an ID of a virtual subnet. The cmdlet adds an ACL that applies to traffic on the isolated network that you specify. The subnet uses virtual local area network (VLAN) or Hyper-V Network Virtualization. For more information about isolation IDs, see the Set-VmNetworkAdapterIsolation cmdlet.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-LocalIPAddress

Specifies the local IP address for the ACL. For an inbound packet, the local address is the destination IP address. For an outbound packet, the local address is the source IP address. You can specify a host address or a subnet address, or specify a wildcard, such as 0.0.0.0/0 for all IPv4 addresses, ::/0 for all IPv6 addresses, or ANY for all IPv4 and IPv6 addresses.

Type:String
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-LocalPort

Specifies the local port for the ACL. A port range format can also be used (i.e. "49152-49182", for example). For an inbound TCP or UDP packet, the local port is the destination port. For an outbound packet, the local port is the source port.

Type:String
Position:5
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ManagementOS

Indicates that the cmdlet operates on the parent or host operating system. If you specify this parameter, this cmdlet creates an ACL that applies to the parent or host operating system.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Passthru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Protocol

Specifies the protocol that the ACL applies to. The acceptable values for this parameter are:

  • TCP
  • UDP
  • an integer IP protocol ID (use 1 for ICMP)
Type:String
Position:7
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RemoteIPAddress

Specifies the local IP address for the ACL. For an inbound packet, the remote address is the source IP address. For an outbound packet, the remote address is the destination IP address. You can specify a host address or a subnet address, or specify a wildcard, such as 0.0.0.0/0 for all IPv4 addresses, ::/0 for all IPv6 addresses, or ANY for all IPv4 and IPv6 addresses.

Type:String
Position:4
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RemotePort

Specifies the remote port for the ACL. A port range format can also be used (i.e. "49152-49182", for example). For an inbound TCP or UDP packet, the remote port is the source port. For an outbound packet, the remote port is the destination port.

Type:String
Position:6
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Stateful

Indicates whether the ACL applies to packets in both directions of the same session. If you specify a value of $True, the ACL applies to a return packet even though that packet has the opposite direction with respect to the ACL.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VM

Specifies an array of virtual machine objects. The cmdlet adds an ACL for the virtual machines that you specify. To obtain a virtual machine object, use the Get-VM cmdlet.

Type:VirtualMachine[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMName

Specifies an array of names of virtual machines. The cmdlet adds an ACL for the virtual machines that you specify.

Type:String[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMNetworkAdapter

Specifies an array VM network adapters as VMNetworkAdapterBase objects. The cmdlet adds an ACL to the adapters that you specify. To obtain a network adapter, use the Get-VMNetworkAdapter cmdlet.

Type:VMNetworkAdapterBase[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMNetworkAdapterName

Specifies the name of a virtual network adapter. The cmdlet adds an ACL to the adapter that you specify.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Weight

Specifies the weight of an ACL entry. Larger weight values apply first, and once an ACL entry applies to a packet, other entries are no longer relevant for that packet.

Type:Int32
Position:8
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

Microsoft.HyperV.PowerShell.VMNetworkAdapterExtendedAclSetting