Set-AdsState

SYNOPSIS

Writes a AdsState control request to the specified target.

SYNTAX

NetIdPort (Default)

Set-AdsState [-Command] <AdsStateCommand> [[-NetId] <AmsNetId[]>] [[-Port] <Int32>] [-Quiet] [-Force]
 [-StateOnly] [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit]
 [-Reinitialize] [-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]

AddressStr

Set-AdsState [-Command] <AdsStateCommand> [[-Port] <Int32>] [-Address] <String[]> [-Quiet] [-Force]
 [-StateOnly] [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit]
 [-Reinitialize] [-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]

Route

Set-AdsState [-Command] <AdsStateCommand> [[-Port] <Int32>] [-InputObject] <IRoute[]> [-Quiet] [-Force]
 [-StateOnly] [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit]
 [-Reinitialize] [-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]

Session

Set-AdsState [-Command] <AdsStateCommand> -Session <ISession[]> [-Quiet] [-Force] [-StateOnly]
 [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit] [-Reinitialize]
 [-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]

SessionId

Set-AdsState [-Command] <AdsStateCommand> -SessionId <Int32[]> [-Quiet] [-Force] [-StateOnly]
 [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit] [-Reinitialize]
 [-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This Cmdlet sets the ADS State of the specified TwinCAT Targets/AdsServers (E.g. Start / Stop / Config / Reconfig/ Reset) For setting the SystemService (Port 10000) please see also the 'Restart-TwinCAT' Cmdlet, which is optimized for that case.

EXAMPLES

Example 1

PS> Set-AdsState -port 851 -command Run -force

Ok Target    NetId             Port  ErrorCode            Requested   Original Reached Latency (ms)
-- ------    -----             ----  ---------            ---------   -------- ------- ------------
X  CX-11111  1.1.1.1.1.1        851  NoError              Run         Stop     Run     293

Sets the Local PLC on port 851 to RUN. The 'X' in the 'Ok' Column indicates the success.

Example 2

PS> Set-AdsState -port 10000 -command Reset -force

Ok Target     NetId             Port  ErrorCode Requested Original Reached Latency(ms)
-- ------     -----             ----  --------- --------- -------- ------- ------------
X  MySystem   172.168.0.1.1.1  10000  NoError   Reset     Run      Run     5007

Restart the local System Service

Example 3

PS> $r = get-AdsRoute
PS> Set-AdsState -port 851 -command Run -InputObject $r -force

Ok Target    NetId             Port  ErrorCode            Requested   Original Reached Latency (ms)
-- ------    -----             ----  ---------            ---------   -------- ------- ------------
X  CX-11111  1.1.1.1.1.1        851  NoError              Run         Stop     Run     293
X  CX-22222  1.1.1.2.1.1        851  NoError              Run         Stop     Run     357
X  CX-22222  1.1.1.3.1.1        851  NoError              Run         Stop     Run     218
X  CX-22222  1.1.1.4.1.1        851  NoError              Run         Stop     Run     324

Start the PLC on all registered target systems.

PARAMETERS

-Command

The state command. The state.

Possible values: None, Reset, Start, Stop, Reconfig, Run

Type: AdsStateCommand
Parameter Sets: (All)
Aliases:
Accepted values: None, Reset, Start, Stop, Reconfig, Run

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

-NetId

The NetId address where to set the state (Local system by default). Multiple values are allowed. 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

-Port

Port Address of the AdsServer where to set the state (Port 10000, SystemService by default) Tab completion: Completes well-known ADS port numbers and names (e.g., 851/Plc1, 10000/SystemService). The port.

Type: Int32
Parameter Sets: NetIdPort, AddressStr, Route
Aliases:

Required: False
Position: 2
Default value: 10000
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

Target route(s), where to set the state. Multiple values are allowed. 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: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Address

The address of the system where to set the state. This can be the RouteName, NetId, the HostName or the IPAddress. Wildcards and multiple values 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

-Session

The ADS Session to use for the Cmdlet. Multiple sessions are allowed. The address.

Type: ISession[]
Parameter Sets: Session
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-SessionId

Specifies the Session (with unique ID) to use for the Cmdlet (multiple values are allowed) Tab completion: Completes IDs of active TwinCAT sessions (created with New-TcSession). The Session ID.

Type: Int32[]
Parameter Sets: SessionId
Aliases:

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

-Quiet

Sets the Quiet mode of the command. The Cmdlet then returns a $true or $false but not the actual states of the targets. The return value will be $true if all operations succeed and it will be $false if at least one have failed. The quiet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Force

Forces the command (no confirmation) The quiet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-StateOnly

The StateOnly mode Instead of returning WriteControlInfoEx objects, the reached AdsState is returned for each requested address.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Timeout

The communication ADS timeout in milliseconds. A value <= 0 sets the Default Timeout (5000 ms). The ADS communication timeout in milliseconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-WaitTimeout

The wait timout for the state change in ms. This Cmdlet waits for the target state changes which is limited by this WaitTimeout. A value <= 0 sets the Default (45000 ms). This parameter is only used if -NoWait is not set. The wait timeout in milliseconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-PollingRate

The Wait polling rate in Milliseconds. A value <= 0 sets the Default polling rate (200 ms for local systems, 1000ms for remote systems). This parameter is only used, if -NoWait is not set. The Polling rate in millisenconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-ThrowError

Throws an error, if the target system(s) not reaching the expected state. True activates the Error generation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-NoReinit

Skips the WriteControl command if the target system is already in the requested state. When set, the Cmdlet returns immediately without reinitializing an already-matching state. When set, the target state is checked first; if it already matches the requested state, no WriteControl is sent.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Reinitialize

This parameter is obsolete This parameter forces the reinitialization of the target. It is the opposite of the -NoReinit parameter. True activates the reinitialization.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-NoWait

The -NoWait parameter skips the waiting for the target end state. If set, the Cmdlet returns immediatly after sending the WriteControl request, without waiting for the state change. When set, the Cmdlet does not wait for the target to reach the requested state.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

-WhatIf

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

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
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.

INPUTS

TwinCAT.IRoute[]

TwinCAT.ISession[]

OUTPUTS

NOTES