Add-SCNATRule

Adds a NAT rule.

Syntax

Add-SCNATRule
   [-VMMServer <ServerConnection>]
   [-NATConnection] <NATConnection>
   -Name <String>
   -InternalIPAddress <String>
   -ExternalPort <UInt32>
   -InternalPort <UInt32>
   [-Protocol <Protocol>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]

Description

The Add-SCNATRule cmdlet adds a network address translation (NAT) rule.

Examples

Example1: Add NAT rule to a virtual machine network for a virtual machine

PS C:\> $VmNetwork = Get-SCVMNetwork -Name "NAT_VMNetwork"
PS C:\> $NatConnection = Get-SCNATConnection -VMNetwork $VmNetwork
PS C:\> Add-SCNATRule -NATConnection $NatConnection -ExternalPort 8081 -InternalIPAddress 10.10.10.9 -InternalPort 8081 -Protocol "TCP" -Name "NatRule"

The first command gets the virtual machine network by its name and stores it in the $VmNetwork variable.

The second command gets NAT connection for the virtual machine network and stores it in the $NatConnection variable.

The third command creates a nat rule with the name NatRule, an internal IP address of virtual machine 10.10.10.9, an internal port 8081, an external port 8081, and the protocol TCP.

Parameters

-ExternalPort

Specifies an external port number.

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

-InternalIPAddress

Specifies an internal IP address.

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

-InternalPort

Specifies an internal port number.

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

-JobVariable

Specifies a variable in which job progress is tracked and stored.

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

-Name

Specifies the name of a network object.

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

-NATConnection

Specifies a NAT connection object.

Type:NATConnection
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

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

-OnBehalfOfUserRole

Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.

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

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

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

-Protocol

Specifies a protocol. The acceptable values for this parameter are:

  • TCP
  • UDP
Type:Protocol
Accepted values:TCP, UDP
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

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

-VMMServer

Specifies a Virtual Machine Manager (VMM) server object.

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