# Invoke-RASRDSHostSessionCmd

## NAME

Invoke-RASRDSHostSessionCmd

## SYNOPSIS

Sends RDS session commands.

## SYNTAX

**Invoke-RASRDSHostSessionCmd** \[-[InputObject](#InputObject)] _<_[_RDPSession_](../classes-and-enumerations/rdpsession)_>_ -[Command](#Command) {LogOff | SendMsg | Disconnect} \[-[Message](#Message) _\<string>_] \[-[MsgTitle](#MsgTitle) _\<string>_] \[_<_[_CommonParameters_](#CommonParameters)_>_]

**Invoke-RASRDSHostSessionCmd** \[-[RDSId](#RDSId)] _\<uint>_ -[Command](#Command) {LogOff | SendMsg | Disconnect} -[Id](#Id) _\<uint>_ \[-[Message](#Message) _\<string>_] \[-[MsgTitle](#MsgTitle) _\<string>_] \[_<_[_CommonParameters_](#CommonParameters)_>_]

**Invoke-RASRDSHostSessionCmd** \[-[RDSServer](#RDSServer)] _\<string>_ \[\[-[SiteId](#SiteId)] _\<uint>_] -[Command](#Command) {LogOff | SendMsg | Disconnect} -[Id](#Id) _\<uint>_ \[-[Message](#Message) _\<string>_] \[-[MsgTitle](#MsgTitle) _\<string>_] \[_<_[_CommonParameters_](#CommonParameters)_>_]

## DESCRIPTION

Sends a session command such as LogOff, Disconnect, or Send Message.

It will only fail with an error if the name or ID of the RD Session Host server is invalid or command does not reach the destination.

If the session ID is invalid, the command will not fail.

## PARAMETERS

-**RDSServer \<string>**\
The name of a RD Session Host server.

The name can be either FQDN or IP address, but you have to enter the actual name this server has in the RAS farm.

```
        Required?                    true

        Position?                    0

        Default value                

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**SiteId \<uint>**\
Site ID.

If the parameter is omitted, the Licensing Server site ID will be used.

```
        Required?                    false

        Position?                    1

        Default value                0

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**RDSId \<uint>**\
The ID of a RD Session Host server.

To obtain the ID, use the Get-RDS cmdlet.

```
        Required?                    true

        Position?                    0

        Default value                0

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**Id \<uint>**\
Session ID.

To obtain the RDS Session ID, use the Get-RDSStatus command with StatusLevel as Level2.

```
        Required?                    true

        Position?                    named

        Default value                0

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**InputObject <**[**RDPSession**](../classes-and-enumerations/rdpsession)**>**\
The RDS Session Object.

To obtain a RDSSession object representing a RD Session, use the Get-RDSStatus command with StatusLevel as Level2."

```
        Required?                    true

        Position?                    0

        Default value                

        Accept pipeline input?       true (ByValue)

        Accept wildcard characters?  false
```

-**Command <**[**RDSSessionCmd**](../classes-and-enumerations/rdssessioncmd)**>**\
Session command.

Accepted values: LogOff, SendMsg, Disconnect.

Possible values: LogOff, SendMsg, Disconnect

```
        Required?                    true

        Position?                    named

        Default value                0

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**MsgTitle \<string>**\
The message title for the session message.

```
        Required?                    false

        Position?                    named

        Default value                

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

-**Message \<string>**\
The session message to be sent.

```
        Required?                    false

        Position?                    named

        Default value                

        Accept pipeline input?       false

        Accept wildcard characters?  false
```

\<CommonParameters>

```
        This cmdlet supports the common parameters: Verbose, Debug,

        ErrorAction, ErrorVariable, WarningAction, WarningVariable,

        OutBuffer, PipelineVariable, and OutVariable. For more information, see 

        about_CommonParameters documentation. 
```

## INPUTS

[RDPSession](../classes-and-enumerations/rdpsession)

## OUTPUTS

-none-

## EXAMPLES

**---------- EXAMPLE 1 ----------**

Invoke-RASRDSHostSessionCmd "server.company.dom" -Command LogOff -Id 6

Send the LogOff command to the server specified by name in the Licensing Server site (default).

To obtain the session ID, use the Get-RDSStatus cmdlet with StatusLevel as Level2.\
&#xNAN;**---------- EXAMPLE 2 ----------**

Invoke-RASRDSHostSessionCmd -RDSId 10 -Command SendMsg -Id 6 -Message "This is a message"

Send the SendMsg command to the server specified by ID to send the specified message.

To obtain the ID, use the Get-RASRDSHost cmdlet.

To obtain the session ID, use the Get-RASRDSHostStatus cmdlet with StatusLevel as Level2.\
&#xNAN;**---------- EXAMPLE 3 ----------**

$RDPSession | Invoke-RASRDSHostSessionCmd -Command Disconnect

Send the Disconnect command for the session, which is identified by an object obtained from the pipeline output.

To obtain the $RDPSession object, use the Get-RASRDSHostStatus cmdlet with StatusLevel as Level2.

## RELATED LINKS

* [Get-RASRDSHost](get-rasrdshost)
* [Get-RASRDSHostStatus](get-rasrdshoststatus)
* [Invoke-RASRDSHostCmd](invoke-rasrdshostcmd)
* [Invoke-RASRDSHostProcessCmd](invoke-rasrdshostprocesscmd)
