

的版本 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_appstream_code_examples"></a>

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

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

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

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

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

### `Add-APSResourceTag`
<a name="appstream_TagResource_powershell_topic"></a>

以下代码示例演示了如何使用 `Add-APSResourceTag`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例向资源添加 AppStream 资源标签**  

```
Add-APSResourceTag -ResourceArn arn:aws:appstream:us-east-1:123456789012:stack/SessionScriptTest -Tag @{StackState='Test'} -Select ^Tag
```
**输出**：  

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

### `Copy-APSImage`
<a name="appstream_CopyImage_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将映像复制到其它区域**  

```
Copy-APSImage -DestinationImageName TestImageCopy -DestinationRegion us-west-2 -SourceImageName Powershell
```
**输出**：  

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

### `Disable-APSUSer`
<a name="appstream_DisableUser_powershell_topic"></a>

以下代码示例演示了如何使用 `Disable-APSUSer`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例禁用 USERPOOL 中的用户**  

```
Disable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DisableUser](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Enable-APSUser`
<a name="appstream_EnableUser_powershell_topic"></a>

以下代码示例演示了如何使用 `Enable-APSUser`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例在 USERPOOL 中启用禁用的用户**  

```
Enable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [EnableUser](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSAssociatedFleetList`
<a name="appstream_ListAssociatedFleets_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示与堆栈关联的实例集**  

```
Get-APSAssociatedFleetList -StackName PowershellStack
```
**输出**：  

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

### `Get-APSAssociatedStackList`
<a name="appstream_ListAssociatedStacks_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示与实例集关联的堆栈**  

```
Get-APSAssociatedStackList -FleetName PowershellFleet
```
**输出**：  

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

### `Get-APSDirectoryConfigList`
<a name="appstream_DescribeDirectoryConfigs_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示了在中创建的目录配置 AppStream**  

```
Get-APSDirectoryConfigList | Select DirectoryName, OrganizationalUnitDistinguishedNames, CreatedTime
```
**输出**：  

```
DirectoryName OrganizationalUnitDistinguishedNames CreatedTime
------------- ------------------------------------ -----------
Test.com      {OU=AppStream,DC=Test,DC=com}    9/6/2019 10:56:40 AM
contoso.com   {OU=AppStream,OU=contoso,DC=contoso,DC=com}  8/9/2019 9:08:50 AM
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeDirectoryConfigs](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSFleetList`
<a name="appstream_DescribeFleets_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示实例集的详细信息**  

```
Get-APSFleetList -Name Test
```
**输出**：  

```
Arn                            : arn:aws:appstream:us-east-1:1234567890:fleet/Test
ComputeCapacityStatus          : Amazon.AppStream.Model.ComputeCapacityStatus
CreatedTime                    : 9/12/2019 5:00:45 PM
Description                    : Test
DisconnectTimeoutInSeconds     : 900
DisplayName                    : Test
DomainJoinInfo                 :
EnableDefaultInternetAccess    : False
FleetErrors                    : {}
FleetType                      : ON_DEMAND
IamRoleArn                     :
IdleDisconnectTimeoutInSeconds : 900
ImageArn                       : arn:aws:appstream:us-east-1:1234567890:image/Test
ImageName                      : Test
InstanceType                   : stream.standard.medium
MaxUserDurationInSeconds       : 57600
Name                           : Test
State                          : STOPPED
VpcConfig                      : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeFleets](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSImageBuilderList`
<a name="appstream_DescribeImageBuilders_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示了以下内容的详细信息 ImageBuilder**  

```
Get-APSImageBuilderList -Name TestImage
```
**输出**：  

```
AccessEndpoints             : {}
AppstreamAgentVersion       : 06-19-2019
Arn                         : arn:aws:appstream:us-east-1:1234567890:image-builder/TestImage
CreatedTime                 : 1/14/2019 4:33:05 AM
Description                 :
DisplayName                 : TestImage
DomainJoinInfo              :
EnableDefaultInternetAccess : False
IamRoleArn                  :
ImageArn                    : arn:aws:appstream:us-east-1::image/Base-Image-Builder-05-02-2018
ImageBuilderErrors          : {}
InstanceType                : stream.standard.large
Name                        : TestImage
NetworkAccessConfiguration  : Amazon.AppStream.Model.NetworkAccessConfiguration
Platform                    : WINDOWS
State                       : STOPPED
StateChangeReason           :
VpcConfig                   : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeImageBuilders](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSImageList`
<a name="appstream_DescribeImages_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示私有 AppStream 图片**  

```
Get-APSImageList -Type PRIVATE | select DisplayName, ImageBuilderName, Visibility, arn
```
**输出**：  

```
DisplayName          ImageBuilderName      Visibility Arn
-----------          ----------------      ---------- ---
OfficeApps           OfficeApps            PRIVATE    arn:aws:appstream:us-east-1:123456789012:image/OfficeApps
SessionScriptV2      SessionScriptTest     PRIVATE    arn:aws:appstream:us-east-1:123456789012:image/SessionScriptV2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeImages](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSImagePermission`
<a name="appstream_DescribeImagePermissions_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示共享图像的 AppStream 图像权限**  

```
Get-APSImagePermission -Name Powershell  | select SharedAccountId, @{n="AllowFleet";e={$_.ImagePermissions.AllowFleet}}, @{n="AllowImageBuilder";e={$_.ImagePermissions.AllowImageBuilder}}
```
**输出**：  

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

### `Get-APSSessionList`
<a name="appstream_DescribeSessions_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示实例集的会话列表**  

```
Get-APSSessionList -FleetName PowershellFleet -StackName PowershellStack
```
**输出**：  

```
AuthenticationType         : API
ConnectionState            : CONNECTED
FleetName                  : PowershellFleet
Id                         : d8987c70-4394-4324-a396-2d485c26f2a2
MaxExpirationTime          : 12/27/2019 4:54:07 AM
NetworkAccessConfiguration : Amazon.AppStream.Model.NetworkAccessConfiguration
StackName                  : PowershellStack
StartTime                  : 12/26/2019 12:54:12 PM
State                      : ACTIVE
UserId                     : Test
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeSessions](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSStackList`
<a name="appstream_DescribeStacks_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示 AppStream 堆栈列表**  

```
Get-APSStackList | Select DisplayName, Arn, CreatedTime
```
**输出**：  

```
DisplayName                   Arn                                                                          CreatedTime
-----------                   ---                                                                          -----------
PowershellStack               arn:aws:appstream:us-east-1:123456789012:stack/PowershellStack               4/24/2019 8:49:29 AM
SessionScriptTest             arn:aws:appstream:us-east-1:123456789012:stack/SessionScriptTest             9/12/2019 3:23:12 PM
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeStacks](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSTagsForResourceList`
<a name="appstream_ListTagsForResource_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示 AppStream 资源上的标签**  

```
Get-APSTagsForResourceList -ResourceArn arn:aws:appstream:us-east-1:123456789012:stack/SessionScriptTest
```
**输出**：  

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

### `Get-APSUsageReportSubscription`
<a name="appstream_DescribeUsageReportSubscriptions_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示 AppStreamUsageReport 配置详细信息**  

```
Get-APSUsageReportSubscription
```
**输出**：  

```
LastGeneratedReportDate S3BucketName                                   Schedule SubscriptionErrors
----------------------- ------------                                   -------- ------------------
1/1/0001 12:00:00 AM    appstream-logs-us-east-1-123456789012-sik1hnxe DAILY    {}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeUsageReportSubscriptions](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSUser`
<a name="appstream_DescribeUsers_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示处于启用状态的用户列表**  

```
Get-APSUser -AuthenticationType USERPOOL | Select-Object UserName, AuthenticationType, Enabled
```
**输出**：  

```
UserName                   AuthenticationType Enabled
--------                   ------------------ -------
foo1@contoso.com USERPOOL              True
foo2@contoso.com        USERPOOL              True
foo3@contoso.com    USERPOOL              True
foo4@contoso.com   USERPOOL              True
foo5@contoso.com         USERPOOL              True
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeUsers](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Get-APSUserStackAssociation`
<a name="appstream_DescribeUserStackAssociations_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例显示分配给堆栈的用户列表**  

```
Get-APSUserStackAssociation -StackName PowershellStack
```
**输出**：  

```
AuthenticationType SendEmailNotification StackName       UserName
------------------ --------------------- ---------       --------
USERPOOL           False                 PowershellStack TestUser1@lab.com
USERPOOL           False                 PowershellStack TestUser2@lab.com
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeUserStackAssociations](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSDirectoryConfig`
<a name="appstream_CreateDirectoryConfig_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例在中创建目录配置 AppStream**  

```
New-APSDirectoryConfig -ServiceAccountCredentials_AccountName contoso\ServiceAccount -ServiceAccountCredentials_AccountPassword MyPass -DirectoryName contoso.com -OrganizationalUnitDistinguishedName "OU=AppStream,OU=Contoso,DC=Contoso,DC=com"
```
**输出**：  

```
CreatedTime            DirectoryName OrganizationalUnitDistinguishedNames        ServiceAccountCredentials
-----------            ------------- ------------------------------------        -------------------------
12/27/2019 11:00:30 AM contoso.com   {OU=AppStream,OU=Contoso,DC=Contoso,DC=com} Amazon.AppStream.Model.ServiceAccountCredentials
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateDirectoryConfig](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSFleet`
<a name="appstream_CreateFleet_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例创建了一个新 AppStream 舰队**  

```
New-APSFleet -ComputeCapacity_DesiredInstance 1 -InstanceType stream.standard.medium -Name TestFleet -DisplayName TestFleet -FleetType ON_DEMAND -EnableDefaultInternetAccess $True -VpcConfig_SubnetIds "subnet-123ce32","subnet-a1234cfd" -VpcConfig_SecurityGroupIds sg-4d012a34 -ImageName SessionScriptTest -Region us-west-2
```
**输出**：  

```
Arn                            : arn:aws:appstream:us-west-2:123456789012:fleet/TestFleet
ComputeCapacityStatus          : Amazon.AppStream.Model.ComputeCapacityStatus
CreatedTime                    : 12/27/2019 11:24:42 AM
Description                    :
DisconnectTimeoutInSeconds     : 900
DisplayName                    : TestFleet
DomainJoinInfo                 :
EnableDefaultInternetAccess    : True
FleetErrors                    : {}
FleetType                      : ON_DEMAND
IamRoleArn                     :
IdleDisconnectTimeoutInSeconds : 0
ImageArn                       : arn:aws:appstream:us-west-2:123456789012:image/SessionScriptTest
ImageName                      : SessionScriptTest
InstanceType                   : stream.standard.medium
MaxUserDurationInSeconds       : 57600
Name                           : TestFleet
State                          : STOPPED
VpcConfig                      : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateFleet](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSImageBuilder`
<a name="appstream_CreateImageBuilder_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例在中创建了 Image Builder AppStream**  

```
New-APSImageBuilder -InstanceType stream.standard.medium -Name TestIB -DisplayName TestIB -ImageName AppStream-WinServer2012R2-12-12-2019 -EnableDefaultInternetAccess $True -VpcConfig_SubnetId subnet-a1234cfd -VpcConfig_SecurityGroupIds sg-2d012a34 -Region us-west-2
```
**输出**：  

```
AccessEndpoints             : {}
AppstreamAgentVersion       : 12-16-2019
Arn                         : arn:aws:appstream:us-west-2:123456789012:image-builder/TestIB
CreatedTime                 : 12/27/2019 11:39:24 AM
Description                 :
DisplayName                 : TestIB
DomainJoinInfo              :
EnableDefaultInternetAccess : True
IamRoleArn                  :
ImageArn                    : arn:aws:appstream:us-west-2::image/AppStream-WinServer2012R2-12-12-2019
ImageBuilderErrors          : {}
InstanceType                : stream.standard.medium
Name                        : TestIB
NetworkAccessConfiguration  :
Platform                    : WINDOWS
State                       : PENDING
StateChangeReason           :
VpcConfig                   : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateImageBuilder](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSImageBuilderStreamingURL`
<a name="appstream_CreateImageBuilderStreamingURL_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例创建了一个有效期为 2 小时的 ImageBuilder 直播网址**  

```
New-APSImageBuilderStreamingURL -Name TestIB -Validity 7200 -Region us-west-2
```
**输出**：  

```
Expires               StreamingURL
-------               ------------
12/27/2019 1:49:13 PM https://appstream2.us-west-2.aws.amazon.com/authenticate?parameters=eyJ0eXBlIjoiQURNSU4iLCJleHBpcmVzIjoiMTU3NzQ1NDU1MyIsImF3c0FjY291bnRJZCI6IjM5MzQwMzgxMTQwNyIsInVzZXJJZCI6ImFkbWluIiwiY2F
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) 中的[CreateImageBuilderStreaming网址](https://docs.aws.amazon.com/powershell/v5/reference)。

### `New-APSStack`
<a name="appstream_CreateStack_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例创建了一个新 AppStream 堆栈**  

```
New-APSStack -Name TestStack -DisplayName TestStack -ApplicationSettings_Enabled $True -ApplicationSettings_SettingsGroup TestStack -Region us-west-2
```
**输出**：  

```
AccessEndpoints     : {}
ApplicationSettings : Amazon.AppStream.Model.ApplicationSettingsResponse
Arn                 : arn:aws:appstream:us-west-2:123456789012:stack/TestStack
CreatedTime         : 12/27/2019 12:34:19 PM
Description         :
DisplayName         : TestStack
EmbedHostDomains    : {}
FeedbackURL         :
Name                : TestStack
RedirectURL         :
StackErrors         : {}
StorageConnectors   : {}
UserSettings        : {Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateStack](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSStreamingURL`
<a name="appstream_CreateStreamingURL_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例创建堆栈的流式传输 URL**  

```
New-APSStreamingURL -StackName SessionScriptTest -FleetName SessionScriptNew -UserId TestUser
```
**输出**：  

```
Expires                StreamingURL
-------                ------------
12/27/2019 12:43:37 PM https://appstream2.us-east-1.aws.amazon.com/authenticate?parameters=eyJ0eXBlIjoiRU5EX1VTRVIiLCJleHBpcmVzIjoiMTU3NzQ1MDYxNyIsImF3c0FjY291bnRJZCI6IjM5MzQwMzgxMTQwNyIsInVzZXJJZCI6IlRlc3RVc2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) 中的[CreateStreaming网址](https://docs.aws.amazon.com/powershell/v5/reference)。

### `New-APSUsageReportSubscription`
<a name="appstream_CreateUsageReportSubscription_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例启用 AppStream 使用情况报告**  

```
New-APSUsageReportSubscription
```
**输出**：  

```
S3BucketName                                   Schedule
------------                                   --------
appstream-logs-us-east-1-123456789012-sik2hnxe DAILY
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [CreateUsageReportSubscription](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `New-APSUser`
<a name="appstream_CreateUser_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例在 USERPOOL 中创建一个用户**  

```
New-APSUser -UserName Test@lab.com -AuthenticationType USERPOOL -FirstName 'kt' -LastName 'aws' -Select ^UserName
```
**输出**：  

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

### `Register-APSFleet`
<a name="appstream_AssociateFleet_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例使用堆栈注册实例集**  

```
Register-APSFleet -StackName TestStack -FleetName TestFleet -Region us-west-2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [AssociateFleet](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Register-APSUserStackBatch`
<a name="appstream_BatchAssociateUserStack_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将堆栈分配给 USERPOOL 中的用户**  

```
Register-APSUserStackBatch -UserStackAssociation @{AuthenticationType="USERPOOL";SendEmailNotification=$False;StackName="PowershellStack";UserName="TestUser1@lab.com"}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [BatchAssociateUserStack](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-APSDirectoryConfig`
<a name="appstream_DeleteDirectoryConfig_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例删除了 AppStream 目录配置**  

```
Remove-APSDirectoryConfig -DirectoryName contoso.com
```
**输出**：  

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

### `Remove-APSFleet`
<a name="appstream_DeleteFleet_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例移除已删除的 AppStream 舰队**  

```
Remove-APSFleet -Name TestFleet -Region us-west-2
```
**输出**：  

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

### `Remove-APSImage`
<a name="appstream_DeleteImage_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例删除映像**  

```
Remove-APSImage -Name TestImage -Region us-west-2
```
**输出**：  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-APSImage (DeleteImage)" on target "TestImage".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A

Applications                : {}
AppstreamAgentVersion       : LATEST
Arn                         : arn:aws:appstream:us-west-2:123456789012:image/TestImage
BaseImageArn                :
CreatedTime                 : 12/27/2019 1:34:10 PM
Description                 :
DisplayName                 : TestImage
ImageBuilderName            :
ImageBuilderSupported       : True
ImagePermissions            :
Name                        : TestImage
Platform                    : WINDOWS
PublicBaseImageReleasedDate : 6/12/2018 12:00:00 AM
State                       : AVAILABLE
StateChangeReason           :
Visibility                  : PRIVATE
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DeleteImage](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-APSImageBuilder`
<a name="appstream_DeleteImageBuilder_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例删除了 ImageBuilder**  

```
Remove-APSImageBuilder -Name TestIB -Region us-west-2
```
**输出**：  

```
Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-APSImageBuilder (DeleteImageBuilder)" on target "TestIB".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A

AccessEndpoints             : {}
AppstreamAgentVersion       : 12-16-2019
Arn                         : arn:aws:appstream:us-west-2:123456789012:image-builder/TestIB
CreatedTime                 : 12/27/2019 11:39:24 AM
Description                 :
DisplayName                 : TestIB
DomainJoinInfo              :
EnableDefaultInternetAccess : True
IamRoleArn                  :
ImageArn                    : arn:aws:appstream:us-west-2::image/AppStream-WinServer2012R2-12-12-2019
ImageBuilderErrors          : {}
InstanceType                : stream.standard.medium
Name                        : TestIB
NetworkAccessConfiguration  : Amazon.AppStream.Model.NetworkAccessConfiguration
Platform                    : WINDOWS
State                       : DELETING
StateChangeReason           :
VpcConfig                   : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DeleteImageBuilder](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Remove-APSImagePermission`
<a name="appstream_DeleteImagePermissions_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例移除映像的权限**  

```
Remove-APSImagePermission -Name Powershell -SharedAccountId 123456789012
```
**输出**：  

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

### `Remove-APSResourceTag`
<a name="appstream_UntagResource_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例从资源中移除 AppStream 资源标签**  

```
Remove-APSResourceTag -ResourceArn arn:aws:appstream:us-east-1:123456789012:stack/SessionScriptTest -TagKey StackState
```
**输出**：  

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

### `Remove-APSStack`
<a name="appstream_DeleteStack_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例删除堆栈**  

```
Remove-APSStack -Name TestStack -Region us-west-2
```
**输出**：  

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

### `Remove-APSUsageReportSubscription`
<a name="appstream_DeleteUsageReportSubscription_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例禁用 AppStream 使用情况报告订阅**  

```
Remove-APSUsageReportSubscription
```
**输出**：  

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

### `Remove-APSUser`
<a name="appstream_DeleteUser_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例从 USERPOOL 中删除用户**  

```
Remove-APSUser -UserName TestUser@lab.com -AuthenticationType USERPOOL
```
**输出**：  

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

### `Revoke-APSSession`
<a name="appstream_ExpireSession_powershell_topic"></a>

以下代码示例演示了如何使用 `Revoke-APSSession`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例撤消了与舰队的会话 AppStream **  

```
Revoke-APSSession -SessionId 6cd2f9a3-f948-4aa1-8014-8a7dcde14877
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ExpireSession](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Start-APSFleet`
<a name="appstream_StartFleet_powershell_topic"></a>

以下代码示例演示了如何使用 `Start-APSFleet`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例启动实例集**  

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

### `Start-APSImageBuilder`
<a name="appstream_StartImageBuilder_powershell_topic"></a>

以下代码示例演示了如何使用 `Start-APSImageBuilder`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例启动一个 ImageBuilder**  

```
Start-APSImageBuilder -Name TestImage
```
**输出**：  

```
AccessEndpoints             : {}
AppstreamAgentVersion       : 06-19-2019
Arn                         : arn:aws:appstream:us-east-1:123456789012:image-builder/TestImage
CreatedTime                 : 1/14/2019 4:33:05 AM
Description                 :
DisplayName                 : TestImage
DomainJoinInfo              :
EnableDefaultInternetAccess : False
IamRoleArn                  :
ImageArn                    : arn:aws:appstream:us-east-1::image/Base-Image-Builder-05-02-2018
ImageBuilderErrors          : {}
InstanceType                : stream.standard.large
Name                        : TestImage
NetworkAccessConfiguration  : Amazon.AppStream.Model.NetworkAccessConfiguration
Platform                    : WINDOWS
State                       : PENDING
StateChangeReason           :
VpcConfig                   : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [StartImageBuilder](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Stop-APSFleet`
<a name="appstream_StopFleet_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例停止实例集**  

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

### `Stop-APSImageBuilder`
<a name="appstream_StopImageBuilder_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例停止 ImageBuilder**  

```
Stop-APSImageBuilder -Name TestImage
```
**输出**：  

```
AccessEndpoints             : {}
AppstreamAgentVersion       : 06-19-2019
Arn                         : arn:aws:appstream:us-east-1:123456789012:image-builder/TestImage
CreatedTime                 : 1/14/2019 4:33:05 AM
Description                 :
DisplayName                 : TestImage
DomainJoinInfo              :
EnableDefaultInternetAccess : False
IamRoleArn                  :
ImageArn                    : arn:aws:appstream:us-east-1::image/Base-Image-Builder-05-02-2018
ImageBuilderErrors          : {}
InstanceType                : stream.standard.large
Name                        : TestImage
NetworkAccessConfiguration  : Amazon.AppStream.Model.NetworkAccessConfiguration
Platform                    : WINDOWS
State                       : STOPPING
StateChangeReason           :
VpcConfig                   : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [StopImageBuilder](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Unregister-APSFleet`
<a name="appstream_DisassociateFleet_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例从堆栈中取消注册实例集**  

```
Unregister-APSFleet -StackName TestStack -FleetName TestFleet -Region us-west-2
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DisassociateFleet](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Unregister-APSUserStackBatch`
<a name="appstream_BatchDisassociateUserStack_powershell_topic"></a>

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

**适用于 PowerShell V5 的工具**  
**示例 1：此示例将用户从分配的堆栈中移除**  

```
Unregister-APSUserStackBatch -UserStackAssociation @{AuthenticationType="USERPOOL";SendEmailNotification=$False;StackName="PowershellStack";UserName="TestUser1@lab.com"}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [BatchDisassociateUserStack](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Update-APSDirectoryConfig`
<a name="appstream_UpdateDirectoryConfig_powershell_topic"></a>

以下代码示例演示了如何使用 `Update-APSDirectoryConfig`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例更新了在中创建的目录配置 AppStream**  

```
Update-APSDirectoryConfig -ServiceAccountCredentials_AccountName contoso\ServiceAccount -ServiceAccountCredentials_AccountPassword MyPass@1$@# -DirectoryName contoso.com -OrganizationalUnitDistinguishedName "OU=AppStreamNew,OU=Contoso,DC=Contoso,DC=com"
```
**输出**：  

```
CreatedTime           DirectoryName OrganizationalUnitDistinguishedNames           ServiceAccountCredentials
-----------           ------------- ------------------------------------           -------------------------
12/27/2019 3:50:02 PM contoso.com   {OU=AppStreamNew,OU=Contoso,DC=Contoso,DC=com} Amazon.AppStream.Model.ServiceAccountCredentials
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [UpdateDirectoryConfig](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Update-APSFleet`
<a name="appstream_UpdateFleet_powershell_topic"></a>

以下代码示例演示了如何使用 `Update-APSFleet`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例更新实例集的属性**  

```
Update-APSFleet -Name PowershellFleet -EnableDefaultInternetAccess $True -DisconnectTimeoutInSecond 950
```
**输出**：  

```
Arn                            : arn:aws:appstream:us-east-1:123456789012:fleet/PowershellFleet
ComputeCapacityStatus          : Amazon.AppStream.Model.ComputeCapacityStatus
CreatedTime                    : 4/24/2019 8:39:41 AM
Description                    : PowershellFleet
DisconnectTimeoutInSeconds     : 950
DisplayName                    : PowershellFleet
DomainJoinInfo                 :
EnableDefaultInternetAccess    : True
FleetErrors                    : {}
FleetType                      : ON_DEMAND
IamRoleArn                     :
IdleDisconnectTimeoutInSeconds : 900
ImageArn                       : arn:aws:appstream:us-east-1:123456789012:image/Powershell
ImageName                      : Powershell
InstanceType                   : stream.standard.medium
MaxUserDurationInSeconds       : 57600
Name                           : PowershellFleet
State                          : STOPPED
VpcConfig                      : Amazon.AppStream.Model.VpcConfig
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [UpdateFleet](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Update-APSImagePermission`
<a name="appstream_UpdateImagePermissions_powershell_topic"></a>

以下代码示例演示了如何使用 `Update-APSImagePermission`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例与其他账户共享 AppStream 图片**  

```
Update-APSImagePermission -Name Powershell -SharedAccountId 123456789012 -ImagePermissions_AllowFleet $True -ImagePermissions_AllowImageBuilder $True
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [UpdateImagePermissions](https://docs.aws.amazon.com/powershell/v5/reference)中的。

### `Update-APSStack`
<a name="appstream_UpdateStack_powershell_topic"></a>

以下代码示例演示了如何使用 `Update-APSStack`。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例更新（启用）堆栈上的应用程序设置持久性和主文件夹**  

```
Update-APSStack -Name PowershellStack -ApplicationSettings_Enabled $True -ApplicationSettings_SettingsGroup PowershellStack -StorageConnector @{ConnectorType="HOMEFOLDERS"}
```
**输出**：  

```
AccessEndpoints     : {}
ApplicationSettings : Amazon.AppStream.Model.ApplicationSettingsResponse
Arn                 : arn:aws:appstream:us-east-1:123456789012:stack/PowershellStack
CreatedTime         : 4/24/2019 8:49:29 AM
Description         : PowershellStack
DisplayName         : PowershellStack
EmbedHostDomains    : {}
FeedbackURL         :
Name                : PowershellStack
RedirectURL         :
StackErrors         : {}
StorageConnectors   : {Amazon.AppStream.Model.StorageConnector, Amazon.AppStream.Model.StorageConnector}
UserSettings        : {Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting, Amazon.AppStream.Model.UserSetting}
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [UpdateStack](https://docs.aws.amazon.com/powershell/v5/reference)中的。