Use StopWorkspaces with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use StopWorkspaces with a CLI

The following code examples show how to use StopWorkspaces.

CLI
AWS CLI

To stop an AutoStop WorkSpace

The following stop-workspaces example stops the specified WorkSpace. The WorkSpace must have a running mode of AutoStop.

aws workspaces stop-workspaces \ --stop-workspace-requests WorkspaceId=ws-dk1xzr417

Output:

{ "FailedRequests": [] }

For more information, see Stop and start an AutoStop WorkSpace in the Amazon WorkSpaces Administration Guide.

PowerShell
Tools for PowerShell

Example 1: Stops multiple WorkSpaces.

Stop-WKSWorkspace -WorkspaceId "ws-1a2b3c4d5","ws-6a7b8c9d0"

Example 2: Retrieves the collection of all your WorkSpaces and pipes the IDs to the -WorkSpaceId parameter of Stop-WKSWorkspace causing the WorkSpaces to be stopped.

Get-WKSWorkspaces | Stop-WKSWorkspace

Example 3: This example shows how to pass StopRequest objects defining the WorkSpaces to be stopped.

$arrRequest = @() $request1 = New-Object Amazon.WorkSpaces.Model.StopRequest $request1.WorkspaceId = 'ws-12345678' $arrRequest += $request1 $request2 = New-Object Amazon.WorkSpaces.Model.StopRequest $request2.WorkspaceId = 'ws-abcdefgh' $arrRequest += $request2 Stop-WKSWorkspace -Request $arrRequest
  • For API details, see StopWorkspaces in AWS Tools for PowerShell Cmdlet Reference.