

的版本 5 (V5) AWS Tools for PowerShell 已经发布！

有关重大更改和迁移应用程序的信息，请参阅[迁移主题](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)。

 [https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html](https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html)

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# WorkSpaces 使用适用于 PowerShell V5 的工具的示例
<a name="powershell_workspaces_code_examples"></a>

以下代码示例向您展示了如何使用带 WorkSpaces的 AWS Tools for PowerShell V5 来执行操作和实现常见场景。

*操作*是大型程序的代码摘录，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**Topics**
+ [操作](#actions)

## 操作
<a name="actions"></a>

### `Approve-WKSIpRule`
<a name="workspaces_AuthorizeIpRules_powershell_topic"></a>

以下代码示例演示了如何使用 `Approve-WKSIpRule`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例向现有 IP 组添加规则**  

```
$Rule = @(
@{IPRule = "10.1.0.0/0"; RuleDesc = "First Rule Added"},
@{IPRule = "10.2.0.0/0"; RuleDesc = "Second Rule Added"}
)

Approve-WKSIpRule -GroupId wsipg-abcnx2fcw -UserRule $Rule
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [AuthorizeIpRules](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Copy-WKSWorkspaceImage`
<a name="workspaces_CopyWorkspaceImage_powershell_topic"></a>

以下代码示例演示了如何使用 `Copy-WKSWorkspaceImage`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将具有指定 ID 的工作空间图像从 us-west-2 复制到名为 “” 的当前区域 CopiedImageTest**  

```
Copy-WKSWorkspaceImage -Name CopiedImageTest -SourceRegion us-west-2 -SourceImageId wsi-djfoedhw6
```
**输出**：  

```
wsi-456abaqfe
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CopyWorkspaceImage](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSClientProperty`
<a name="workspaces_ModifyClientProperties_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSClientProperty`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例为 Workspaces 客户端启用重新连接**  

```
Edit-WKSClientProperty -Region us-west-2 -ClientProperties_ReconnectEnabled "ENABLED" -ResourceId d-123414a369
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifyClientProperties](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSSelfServicePermission`
<a name="workspaces_ModifySelfservicePermissions_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSSelfServicePermission`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例启用自助服务权限，以便为指定的目录更改计算类型并增加卷大小**  

```
Edit-WKSSelfservicePermission -Region us-west-2 -ResourceId d-123454a369 -SelfservicePermissions_ChangeComputeType ENABLED -SelfservicePermissions_IncreaseVolumeSize ENABLED
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifySelfservicePermissions](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSWorkspaceAccessProperty`
<a name="workspaces_ModifyWorkspaceAccessProperties_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSWorkspaceAccessProperty`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例在 Android 和 Chrome 操作系统上针对指定目录启用工作空间访问**  

```
Edit-WKSWorkspaceAccessProperty -Region us-west-2 -ResourceId d-123454a369 -WorkspaceAccessProperties_DeviceTypeAndroid ALLOW -WorkspaceAccessProperties_DeviceTypeChromeOs ALLOW
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifyWorkspaceAccessProperties](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSWorkspaceCreationProperty`
<a name="workspaces_ModifyWorkspaceCreationProperties_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSWorkspaceCreationProperty`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例支持在创建工作空间时将互联网访问和维护模式设置为 true 作为默认值**  

```
Edit-WKSWorkspaceCreationProperty -Region us-west-2 -ResourceId d-123454a369 -WorkspaceCreationProperties_EnableInternetAccess $true -WorkspaceCreationProperties_EnableMaintenanceMode $true
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifyWorkspaceCreationProperties](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSWorkspaceProperty`
<a name="workspaces_ModifyWorkspaceProperties_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSWorkspaceProperty`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将指定工作空间的“工作空间运行模式”属性更改为“自动停止”**  

```
Edit-WKSWorkspaceProperty -WorkspaceId ws-w361s100v -Region us-west-2 -WorkspaceProperties_RunningMode AUTO_STOP
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifyWorkspaceProperties](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Edit-WKSWorkspaceState`
<a name="workspaces_ModifyWorkspaceState_powershell_topic"></a>

以下代码示例演示了如何使用 `Edit-WKSWorkspaceState`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将指定工作空间的状态更改为“可用”**  

```
Edit-WKSWorkspaceState -WorkspaceId ws-w361s100v -Region us-west-2 -WorkspaceState AVAILABLE
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ModifyWorkspaceState](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSClientProperty`
<a name="workspaces_DescribeClientProperties_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSClientProperty`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取指定目录的工作空间客户端的客户端属性**  

```
Get-WKSClientProperty -ResourceId d-223562a123
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeClientProperties](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSIpGroup`
<a name="workspaces_DescribeIpGroups_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSIpGroup`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取指定区域中指定 IP 组的详细信息**  

```
Get-WKSIpGroup -Region us-east-1 -GroupId wsipg-8m1234v45
```
**输出**：  

```
GroupDesc GroupId         GroupName UserRules
--------- -------         --------- ---------
          wsipg-8m1234v45 TestGroup {Amazon.WorkSpaces.Model.IpRuleItem, Amazon.WorkSpaces.Model.IpRuleItem}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeIpGroups](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSTag`
<a name="workspaces_DescribeTags_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSTag`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取给定工作空间的标签**  

```
Get-WKSTag -WorkspaceId ws-w361s234r -Region us-west-2
```
**输出**：  

```
Key         Value
---         -----
auto-delete no
purpose     Workbench
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeTags](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspace`
<a name="workspaces_DescribeWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1： WorkSpaces 将您的所有详细信息检索到管道。**  

```
Get-WKSWorkspace
```
**输出**：  

```
BundleId                    : wsb-1a2b3c4d
ComputerName                :
DirectoryId                 : d-1a2b3c4d
ErrorCode                   :
ErrorMessage                :
IpAddress                   :
RootVolumeEncryptionEnabled : False
State                       : PENDING
SubnetId                    :
UserName                    : myuser
UserVolumeEncryptionEnabled : False
VolumeEncryptionKey         :
WorkspaceId                 : ws-1a2b3c4d
WorkspaceProperties         : Amazon.WorkSpaces.Model.WorkspaceProperties
```
**示例 2：此命令显示 `us-west-2` 区域中某个工作空间的 `WorkSpaceProperties` 的各个子属性的值。有关子属性的更多信息`WorkSpaceProperties`，请参阅 https://docs.aws.amazon.com/workspaces/ latest/api/API \$1 WorkspaceProperties .html。**  

```
(Get-WKSWorkspace -Region us-west-2 -WorkSpaceId ws-xdaf7hc9s).WorkspaceProperties
```
**输出**：  

```
        ComputeTypeName                     : STANDARD
        RootVolumeSizeGib                   : 80
        RunningMode                         : AUTO_STOP
        RunningModeAutoStopTimeoutInMinutes : 60
        UserVolumeSizeGib                   : 50
```
**示例 3：此命令显示 `us-west-2` 区域中某个工作空间的 `WorkSpaceProperties` 的子属性 `RootVolumeSizeGib` 的值。根卷大小（以 GiB 为单位）为 80。**  

```
(Get-WKSWorkspace -Region us-west-2 -WorkSpaceId ws-xdaf7hc9s).WorkspaceProperties.RootVolumeSizeGib
```
**输出**：  

```
        80
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspaceBundle`
<a name="workspaces_DescribeWorkspaceBundles_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspaceBundle`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取当前区域中所有工作空间捆绑包的详细信息**  

```
Get-WKSWorkspaceBundle
```
**输出**：  

```
BundleId        : wsb-sfhdgv342
ComputeType     : Amazon.WorkSpaces.Model.ComputeType
Description     : This bundle is custom
ImageId         : wsi-235aeqges
LastUpdatedTime : 12/26/2019 06:44:07
Name            : CustomBundleTest
Owner           : 233816212345
RootStorage     : Amazon.WorkSpaces.Model.RootStorage
UserStorage     : Amazon.WorkSpaces.Model.UserStorage
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspaceBundles](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspaceDirectory`
<a name="workspaces_DescribeWorkspaceDirectories_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspaceDirectory`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例列出已注册目录的目录详细信息**  

```
Get-WKSWorkspaceDirectory
```
**输出**：  

```
Alias                       : TestWorkspace
CustomerUserName            : Administrator
DirectoryId                 : d-123414a369
DirectoryName               : TestDirectory.com
DirectoryType               : MicrosoftAD
DnsIpAddresses              : {172.31.43.45, 172.31.2.97}
IamRoleId                   : arn:aws:iam::761234567801:role/workspaces_RoleDefault
IpGroupIds                  : {}
RegistrationCode            : WSpdx+4RRT43
SelfservicePermissions      : Amazon.WorkSpaces.Model.SelfservicePermissions
State                       : REGISTERED
SubnetIds                   : {subnet-1m3m7b43, subnet-ard11aba}
Tenancy                     : SHARED
WorkspaceAccessProperties   : Amazon.WorkSpaces.Model.WorkspaceAccessProperties
WorkspaceCreationProperties : Amazon.WorkSpaces.Model.DefaultWorkspaceCreationProperties
WorkspaceSecurityGroupId    : sg-0ed2441234a123c43
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspaceDirectories](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspaceImage`
<a name="workspaces_DescribeWorkspaceImages_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspaceImage`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取区域中所有映像的所有详细信息**  

```
Get-WKSWorkspaceImage
```
**输出**：  

```
Description     :This image is copied from another image
ErrorCode       :
ErrorMessage    :
ImageId         : wsi-345ahdjgo
Name            : CopiedImageTest
OperatingSystem : Amazon.WorkSpaces.Model.OperatingSystem
RequiredTenancy : DEFAULT
State           : AVAILABLE
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspaceImages](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspaceSnapshot`
<a name="workspaces_DescribeWorkspaceSnapshots_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspaceSnapshot`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例演示为指定工作空间创建的最新快照的时间戳**  

```
Get-WKSWorkspaceSnapshot -WorkspaceId ws-w361s100v
```
**输出**：  

```
RebuildSnapshots                   RestoreSnapshots
----------------                   ----------------
{Amazon.WorkSpaces.Model.Snapshot} {Amazon.WorkSpaces.Model.Snapshot}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspaceSnapshots](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-WKSWorkspacesConnectionStatus`
<a name="workspaces_DescribeWorkspacesConnectionStatus_powershell_topic"></a>

以下代码示例演示了如何使用 `Get-WKSWorkspacesConnectionStatus`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取指定工作空间的连接状态**  

```
Get-WKSWorkspacesConnectionStatus -WorkspaceId ws-w123s234r
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeWorkspacesConnectionStatus](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-WKSIpGroup`
<a name="workspaces_CreateIpGroup_powershell_topic"></a>

以下代码示例演示了如何使用 `New-WKSIpGroup`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例创建了一个名为的空 IP 组 FreshEmptyIpGroup**  

```
New-WKSIpGroup -GroupName "FreshNewIPGroup"
```
**输出**：  

```
wsipg-w45rty4ty
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateIpGroup](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-WKSTag`
<a name="workspaces_CreateTags_powershell_topic"></a>

以下代码示例演示了如何使用 `New-WKSTag`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例向名为 `ws-wsname` 的工作空间添加一个新标签。该标签的键为“Name”，键值为 `AWS_Workspace`。**  

```
$tag = New-Object Amazon.WorkSpaces.Model.Tag
$tag.Key = "Name"
$tag.Value = "AWS_Workspace"
New-WKSTag -Region us-west-2 -WorkspaceId ws-wsname -Tag $tag
```
**示例 2：此示例向名为 `ws-wsname` 的工作空间添加多个标签。一个标签的键为“Name”，键值为 `AWS_Workspace`；另一个标签的标签键为“Stage”，键值为“Test”。**  

```
$tag = New-Object Amazon.WorkSpaces.Model.Tag
$tag.Key = "Name"
$tag.Value = "AWS_Workspace"

$tag2 = New-Object Amazon.WorkSpaces.Model.Tag
$tag2.Key = "Stage"
$tag2.Value = "Test"
New-WKSTag -Region us-west-2 -WorkspaceId ws-wsname -Tag $tag,$tag2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateTags](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-WKSWorkspace`
<a name="workspaces_CreateWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `New-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1： WorkSpace 为提供的捆绑包、目录和用户创建。**  

```
New-WKSWorkspace -Workspace @{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME"}
```
**示例 2：此示例创建了多个 WorkSpaces**  

```
New-WKSWorkspace -Workspace @{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME_1"},@{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME_2"}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Register-WKSIpGroup`
<a name="workspaces_AssociateIpGroups_powershell_topic"></a>

以下代码示例演示了如何使用 `Register-WKSIpGroup`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将指定的 IP 组注册到指定的目录**  

```
Register-WKSIpGroup -GroupId wsipg-23ahsdres -DirectoryId d-123412e123
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [AssociateIpGroups](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Register-WKSWorkspaceDirectory`
<a name="workspaces_RegisterWorkspaceDirectory_powershell_topic"></a>

以下代码示例演示了如何使用 `Register-WKSWorkspaceDirectory`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例注册 Workspaces 服务的指定目录**  

```
Register-WKSWorkspaceDirectory -DirectoryId d-123412a123 -EnableWorkDoc $false
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [RegisterWorkspaceDirectory](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-WKSIpGroup`
<a name="workspaces_DeleteIpGroup_powershell_topic"></a>

以下代码示例演示了如何使用 `Remove-WKSIpGroup`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例删除指定的 IP 组**  

```
Remove-WKSIpGroup -GroupId wsipg-32fhgtred
```
**输出**：  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-WKSIpGroup (DeleteIpGroup)" on target "wsipg-32fhgtred".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DeleteIpGroup](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-WKSTag`
<a name="workspaces_DeleteTags_powershell_topic"></a>

以下代码示例演示了如何使用 `Remove-WKSTag`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例移除与工作空间关联的标签**  

```
Remove-WKSTag -ResourceId ws-w10b3abcd -TagKey "Type"
```
**输出**：  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-WKSTag (DeleteTags)" on target "ws-w10b3abcd".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DeleteTags](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-WKSWorkspace`
<a name="workspaces_TerminateWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `Remove-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1：终止多个 WorkSpaces。使用-Force 开关会阻止 cmdlet 提示确认。**  

```
Remove-WKSWorkspace -WorkspaceId "ws-1a2b3c4d5","ws-6a7b8c9d0" -Force
```
**示例 2：检索所有你的集合， WorkSpaces 然后通过管道传递 IDs 到 Remove-的-WorkSpaceId 参数WKSWorkspace，终止所有的。 WorkSpacescmdlet 将在每个 WorkSpace 终止之前进行提示。要禁止确认提示，请添加 -Force 开关。**  

```
Get-WKSWorkspaces | Remove-WKSWorkspace
```
**示例 3：此示例说明如何传递定义 WorkSpaces 要终止的 TerminateRequest 对象。除非也指定了 -Force 开关参数，否则在继续操作之前，cmdlet 会提示您进行确认。**  

```
$arrRequest = @()
$request1 = New-Object Amazon.WorkSpaces.Model.TerminateRequest
$request1.WorkspaceId = 'ws-12345678'
$arrRequest += $request1
$request2 = New-Object Amazon.WorkSpaces.Model.TerminateRequest
$request2.WorkspaceId = 'ws-abcdefgh'
$arrRequest += $request2
Remove-WKSWorkspace -Request $arrRequest
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [TerminateWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Reset-WKSWorkspace`
<a name="workspaces_RebuildWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `Reset-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1：重建指定 WorkSpace的。**  

```
Reset-WKSWorkspace -WorkspaceId "ws-1a2b3c4d"
```
**示例 2：检索所有你的集合， WorkSpaces 然后通过管道 IDs 将它们传递给 Reset-的-WorkSpaceId 参数WKSWorkspace，从而重新构建。 WorkSpaces **  

```
Get-WKSWorkspaces | Reset-WKSWorkspace
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [RebuildWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Restart-WKSWorkspace`
<a name="workspaces_RebootWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `Restart-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1：重新启动指定 WorkSpace的。**  

```
Restart-WKSWorkspace -WorkspaceId "ws-1a2b3c4d"
```
**示例 2：多次 WorkSpaces重启。**  

```
Restart-WKSWorkspace -WorkspaceId "ws-1a2b3c4d","ws-5a6b7c8d"
```
**示例 3：检索所有你的集合， WorkSpaces 并将通过管道传递 IDs 给 Restart-的-WorkSpaceId 参数WKSWorkspace，从而 WorkSpaces 使重新启动。**  

```
Get-WKSWorkspaces | Restart-WKSWorkspace
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [RebootWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Stop-WKSWorkspace`
<a name="workspaces_StopWorkspaces_powershell_topic"></a>

以下代码示例演示了如何使用 `Stop-WKSWorkspace`。

**适用于 PowerShell V5 的工具**  
**示例 1：停止多个 WorkSpaces。**  

```
Stop-WKSWorkspace -WorkspaceId "ws-1a2b3c4d5","ws-6a7b8c9d0"
```
**示例 2：检索所有你的集合， WorkSpaces 然后通过管道传递 IDs 给 Stop-的-WorkSpaceId 参数，WKSWorkspace WorkSpaces 从而导致停止。**  

```
Get-WKSWorkspaces | Stop-WKSWorkspace
```
**示例 3：此示例说明如何传递定义 WorkSpaces 要停止的 StopRequest 对象。**  

```
$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
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [StopWorkspaces](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Unregister-WKSIpGroup`
<a name="workspaces_DisassociateIpGroups_powershell_topic"></a>

以下代码示例演示了如何使用 `Unregister-WKSIpGroup`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例从指定的目录中取消注册指定的 IP 组**  

```
Unregister-WKSIpGroup -GroupId wsipg-12abcdphq -DirectoryId d-123454b123
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DisassociateIpGroups](https://docs.aws.amazon.com/powershell/v5/reference)中的。