Get-NsxtService Command | Vmware PowerCLI Reference

Get-NsxtService

This cmdlet retrieves PSObject objects that represent a proxy to a NSX-T API service and can be used to invoke the operations of the NSX-T API service. The cmdlet returns one PSObject object for every service available on NSX-T server.Every service proxy has a top-level Help property that contains documentation about the service's methods, parameters, constants, and so on. The Help object is hierarchical and mirrors the service's methods, parameters, constants, and so on. The Help object can also be used for creation of parameters that the service methods accept through a method named "Create".The "Create" method is available for the following objects:- A parameter.- Inheritors of a parameter that accepts instances of types that derive the declared parameter type.- Elements of a parameter that is of type List, Set or Optional.- Key and Value of a parameter of type Map.- Fields of a parameter of type Structure.For more information, see Example 2.

Syntax

Get-NsxtService
[-Name < String[] > ]
[-ProgressAction < ActionPreference > ]
[-Server < CisServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
optional Name String[] named
  • wildcards
Specifies the service type ID.
optional ProgressAction ActionPreference named
optional Server CisServer[] named
Specifies the NSX-T servers on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-NsxtServer.

Output

System.Management.Automation.PSObject

Examples

Example 1

$userService = Get-NsxtService -Name "com.vmware.nsx.aaa.user_info"
$userService.get()

Retrieves the binding for the specified service and invokes a service operation.

Example 2

# Retrieves the logical routers service.
$logicalRoutersService = Get-NsxtService -Name 'com.vmware.nsx.logical_routers'

# Creates an input argument for the creation of a logical router.
$logicalRouterCreateSpec = $logicalRoutersService.Help.create.logical_router.Create()

# Fills in the create specification properties.
$logicalRouterCreateSpec.display_name = "MyLogicalRouter"
$logicalRouterCreateSpec.router_type = "TIER1"

# Creates the logical router entity.
$logicalRouter = $logicalRoutersService.create($logicalRouterCreateSpec)

# Retrieves the logical router ports service.
$logicalRouterPortsService = Get-NsxtService -Name 'com.vmware.nsx.logical_router_ports'

# Creates the input argument for logical router downlink port creation.
$logicalRouterPortCreateSpec = $logicalRouterPortsService.Help.create.logical_router_port.logical_router_down_link_port.Create()

# Fills in the properties of the logical router port create specification.
$logicalRouterPortCreateSpec.logical_router_id = $logicalRouter.id
$logicalRouterPortCreateSpec.display_name = "MyLogicalRouterDownlinkPort"
$logicalRouterPortCreateSpec.subnets = $logicalRouterPortsService.Help.create.logical_router_port.logical_router_down_link_port.subnets.Create()

# Creates a subnet element.
$subnet = $logicalRouterPortsService.Help.create.logical_router_port.logical_router_down_link_port.subnets.Element.Create()

# Fills in the subnet properties.
$subnet.ip_addresses = @('11.11.11.11')
$subnet.prefix_length = 22

# Adds a subnet to the subnets collection of the logical router port create specification.
$logicalRouterPortCreateSpec.subnets.Add($subnet)

# Creates the logical router downlink port entity.
$logicalRouterPortsService.create($logicalRouterPortCreateSpec)

Creates logical router and logical router downlink port entities.

Related Commands

NsxtService

This cmdlet retrieves PSObject objects that represent a proxy to an NSX-T API service.