There are more AWS SDK examples available in the AWS Doc SDK Examples
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-workspacesexample stops the specified WorkSpace. The WorkSpace must have a running mode ofAutoStop.aws workspaces stop-workspaces \ --stop-workspace-requestsWorkspaceId=ws-dk1xzr417Output:
{ "FailedRequests": [] }For more information, see Stop and start an AutoStop WorkSpace in the Amazon WorkSpaces Administration Guide.
-
For API details, see StopWorkspaces
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
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-WKSWorkspaceExample 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 (V4).
-
- Tools for PowerShell V5
-
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-WKSWorkspaceExample 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 (V5).
-