Restart-TwinCAT

SYNOPSIS

Restarts or Resets a specified TwinCAT System.

SYNTAX

NetId (Default)

Restart-TwinCAT [[-NetId] <AmsNetId[]>] [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <AdsStateCommand>] [-ThrowError]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Route

Restart-TwinCAT [-InputObject] <IRoute[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit]
 [-NoWait] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <AdsStateCommand>] [-ThrowError]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

AddressStr

Restart-TwinCAT [-Address] <String[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <AdsStateCommand>] [-ThrowError]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Session

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

SessionId

Restart-TwinCAT -SessionId <Int32[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <AdsStateCommand>] [-ThrowError]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This Cmdlet Restarts or Resets the specified TwinCAT System dependant of its command parameter.

The TwinCAT system will end up in ADS State 'Run' or 'Config'.

EXAMPLES

EXAMPLE 1

PS> Restart-TwinCat -command Reset -force

WARNING: 192.168.0.2.1.1:10 ERR | 18:26:28:108 |'TCOM Server' (10): Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
WARNING: 192.168.0.2.1.1:10 WRN | 18:26:28:108 |'TCOM Server' (10): PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
WARNING: 192.168.0.2.1.1:10000 ERR | 18:26:28:117 |'TwinCAT System' (10000): Sending ams command >> Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >> AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) << failed!

Ok Target     NetId             Port  ErrorCode Requested Original Reached Latency (ms)
-- ------     -----             ----  --------- --------- -------- ------- ------------
   CX_1111    192.168.0.2.1.1  10000  Succeeded Reset     Config   Config  3427

Calls a Reset to the local SystemService that fails!.

Error log messages will be logged out.

EXAMPLE 2

PS> Restart-TwinCAT -command Reset -force | select-object -ExpandProperty LogMessages

WARNING: 192.168.0.2.1.1:10 ERR | 18:20:45:969 |'TCOM Server' (10): Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
WARNING: 192.168.0.2.1.1:10 WRN | 18:20:45:969 |'TCOM Server' (10): PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
WARNING: 192.168.0.2.1.1:10000 ERR | 18:20:45:979 |'TwinCAT System' (10000): Sending ams command >%gt; Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >%gt; AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) << failed!

Type    TimeStamp    DeviceName     Port  Message
----    ---------    ----------     ----  -------
Message 18:20:44.874 TwinCAT System 10000 TwinCAT System Restart initiated from AmsNetId: 192.168.0.2.1.1 port 34564.
Message 18:20:44.879 TwinCAT System 10000 Saving configuration of COM server TcVnService !
Message 18:20:44.880 TwinCAT System 10000 Saving configuration of COM server TcEventLogger !
Message 18:20:44.970 TwinCAT System 10000 Shutting down COM Server TcVnService !
Message 18:20:44.971 TwinCAT System 10000 Shutting down COM Server TcEventLogger !
Message 18:20:45.745 TwinCAT System 10000 Loading configuration of COM server TcVnService !
Message 18:20:45.747 TwinCAT System 10000 Loading configuration of COM server TcEventLogger !
Message 18:20:45.748 TwinCAT System 10000 Initializing COM Server TcVnService !
Message 18:20:45.773 TwinCAT System 10000 Initializing COM Server TcEventLogger !
Message 18:20:45.783 TwinCAT System 10000 TcIoEth Server started: TcIoEth.
Message 18:20:45.791 TwinCAT System 10000 TcRtsObjects Server started: TcRtsObjects.
Message 18:20:45.798 TwinCAT System 10000 TcIoECat Server started: TcIoECat.
Message 18:20:45.805 TwinCAT System 10000 TcIo Server started: TcIo.
Message 18:20:45.814 TwinCAT System 10000 TcPlc30 Server started: TcPlc30.
Message 18:20:45.821 TwinCAT System 10000 TcRTime Server started: TcRTime.
Message 18:20:45.927 License Server 30    license validation status is Valid(3)
Error   18:20:45.969 TCOM Server    10    Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
Warning 18:20:45.969 TCOM Server    10    PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
Error   18:20:45.979 TwinCAT System 10000 Sending ams command >%gt; Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >%gt; AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) %lt;%lt; failed!
Message 18:20:47.879 TwinCAT System 10000 Loading configuration of COM server TcVnService
Message 18:20:47.881 TwinCAT System 10000 Loading configuration of COM server TcEventLogger
Message 18:20:47.882 TwinCAT System 10000 Initializing COM Server TcVnService
Message 18:20:47.910 TwinCAT System 10000 Initializing COM Server TcEventLogger
Message 18:20:47.922 TwinCAT System 10000 TCIO Server started: TCIO.
Message 18:20:47.931 TwinCAT System 10000 TCRTIME Server started: TCRTIME.
Message 18:20:47.939 TwinCAT System 10000 TCRTSOBJECTS Server started: TCRTSOBJECTS.
Message 18:20:47.948 TwinCAT System 10000 TCIOETH Server started: TCIOETH.
Message 18:20:47.956 TwinCAT System 10000 TCIOECAT Server started: TCIOECAT.
Message 18:20:47.963 TwinCAT System 10000 TCIODRIVERS Server started: TCIODRIVERS.
Message 18:20:48.078 TwinCAT System 10000 Starting COM Server TcVnService
Message 18:20:48.078 TwinCAT System 10000 Starting COM Server TcEventLogger

Tries to restart the local TwinCAT system and write the log messages to the output.

This Command fails.

PARAMETERS

-NetId

The NetId address where to set the state (Local system by default).

Multiple values are allowed.

Type: AmsNetId[]
Parameter Sets: NetId
Aliases:

Required: False
Position: 1
Default value: None
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, Resets the FailFastHandler)

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-StateOnly

This Cmdlet return only the AdsState instead of full information.

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 (5000 ms).

Type: Int32
Parameter Sets: (All)
Aliases:

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

-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

-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

-Command

The timeout to wait for restart.

A value of 0 disables the timeout.

A value \<= 0 sets the Default (5000 ms).

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

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

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

-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