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] [-ProgressAction <ActionPreference>] [-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] [-ProgressAction <ActionPreference>] [-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] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Session

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

SessionId

Set-AdsState [-Command] <AdsStateCommand> -SessionId <Int32[]> [-Quiet] [-Force] [-StateOnly]
 [-Timeout <Int32>] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-ThrowError] [-NoReinit] [-Reinitialize]
 [-NoWait] [-ProgressAction <ActionPreference>] [-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 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 2

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.

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.

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)

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.

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.

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.

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)

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.

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)

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

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).

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.

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.

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.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-NoReinit

Activates a state check before sending WriteControl if the target system is already in the expected target state

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 and will be removed in future versions.

Please use -NoReinit instead.

This parameter forces the reinitialization of the target.

It is the opposite of the -NoReinit parameter.

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.

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

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

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[]

Target route(s), where to set the state.

Multiple values are allowed.

TwinCAT.ISession[]

The ADS Session to use for the Cmdlet.

Multiple sessions are allowed.

OUTPUTS

NOTES