New-TcSession
SYNOPSIS
Create a new session to a TwinCAT Target.
SYNTAX
NetIdPort (Default)
New-TcSession [[-NetId] <AmsNetId>] [-Port] <Int32> [-Force]
[<CommonParameters>]
Route
New-TcSession -InputObject <IRoute> [-Port] <Int32> [-Force]
[<CommonParameters>]
AddressStr
New-TcSession [-Provider <String>] [-Address] <String> [[-Port] <Int32>] [-Force]
[<CommonParameters>]
DESCRIPTION
Creates a new Point-To-Point Connection to a TwinCAT Target that is represented by the returned session object. Different types of Sessions can be accessed by the registered types of SessionProviders (e.g. ADS, MQTT, OPC). If using ADS as protocol, this Cmdlet is equivalent to create and connect an ADSClient. The Address of the remote system is the AmsNetId and AmsPort.
EXAMPLES
Example 1
PS> $route = Get-AdsRoute -Name "Tc3*"
PS> $session = New-TcSession -Route $route -Port 851
PS> $session
ID Address Connected State Cycles Losses LastError Established LastSucceed
-- ------- --------- ----- ------ ------ --------- ----------- -----------
5 172.17.62.105.1.1:851 True Connected 0 0 2016-12-12T12:22:02
Establishes a new ADS Session/Connection to the specified route destination that has the name pattern "tc3*" via port 851 (PLC1)
Example 2
PS> New-TcSession -NetId '172.17.62.105.1.1' -port 851
ID Address Connected State Cycles Losses LastError Established LastSucceed
-- ------- --------- ----- ------ ------ --------- ----------- -----------
5 172.17.62.105.1.1:851 True Connected 0 0 2016-12-12T12:22:02
Establishes a new Ads Session/Connection to the specified NetId/Port address.
Example 3
PS> New-TcSession -Name 'CX_123456' -port 851
ID Address Connected State Cycles Losses LastError Established LastSucceed
-- ------- --------- ----- ------ ------ --------- ----------- -----------
5 172.17.62.105.1.1:851 True Connected 0 0 2016-12-12T12:22:02
Establishes a new Ads Session/Connection to the target system with the Name/HostName 'CX_123456' (Port 851).
PARAMETERS
-NetId
The NetID Address Tab completion: Completes AmsNetId values from currently reachable routes on the local TwinCAT system. The net id.
Type: AmsNetId
Parameter Sets: NetIdPort
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-InputObject
The route target object. Tab completion: Completes route names from currently reachable ADS systems on the local TwinCAT system. The input object.
Type: IRoute
Parameter Sets: Route
Aliases: Destination, Route
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Provider
Selects the session provider registered on the System (ADS by default) Tab completion: Completes available session provider names from the communication service. The address.
Type: String
Parameter Sets: AddressStr
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Address
The target address of the new session. This can be the NetId, the HostName or the IPAddress. Wildcards are permitted. Tab completion: Completes route names from currently reachable ADS systems on the local TwinCAT system. The address.
Type: String
Parameter Sets: AddressStr
Aliases: Name
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True
-Port
The AmsPort Address of the new session. Tab completion: Completes well-known ADS port numbers and names (e.g., 851/Plc1, 10000/SystemService). The port.
Type: Int32
Parameter Sets: NetIdPort, Route
Aliases:
Required: True
Position: 2
Default value: 10000
Accept pipeline input: False
Accept wildcard characters: False
Type: Int32
Parameter Sets: AddressStr
Aliases:
Required: False
Position: 2
Default value: 10000
Accept pipeline input: False
Accept wildcard characters: False
-Force
Forces to create the session independant of ReachableRoutes The Force flag
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.