View a markdown version of this page

WorkSpaces Applications examples using Tools for PowerShell V5 - AWS Tools for PowerShell (version 5)

Version 5 (V5) of the AWS Tools for PowerShell has been released!

For information about breaking changes and migrating your applications, see the migration topic.

Orange button with text "Click here for details".

WorkSpaces Applications examples using Tools for PowerShell V5

The following code examples show you how to perform actions and implement common scenarios by using the AWS Tools for PowerShell V5 with WorkSpaces Applications.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use Add-APSResourceTag.

Tools for PowerShell V5

Example 1: This sample adds a resource Tag to AppStream resource

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

Output:

Name Value ---- ----- StackState Test
  • For API details, see TagResource in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Copy-APSImage.

Tools for PowerShell V5

Example 1: This sample copies an image to other region

Copy-APSImage -DestinationImageName TestImageCopy -DestinationRegion us-west-2 -SourceImageName Powershell

Output:

TestImageCopy
  • For API details, see CopyImage in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Disable-APSUSer.

Tools for PowerShell V5

Example 1: This sample disables an user in USERPOOL

Disable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com
  • For API details, see DisableUser in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Enable-APSUser.

Tools for PowerShell V5

Example 1: This sample enables a disabled user in USERPOOL

Enable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com
  • For API details, see EnableUser in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSAssociatedFleetList.

Tools for PowerShell V5

Example 1: This sample displays fleet associated with a stack

Get-APSAssociatedFleetList -StackName PowershellStack

Output:

PowershellFleet

The following code example shows how to use Get-APSAssociatedStackList.

Tools for PowerShell V5

Example 1: This sample displays stack associated with a fleet

Get-APSAssociatedStackList -FleetName PowershellFleet

Output:

PowershellStack

The following code example shows how to use Get-APSDirectoryConfigList.

Tools for PowerShell V5

Example 1: This sample displays Directory Configurations created in AppStream

Get-APSDirectoryConfigList | Select DirectoryName, OrganizationalUnitDistinguishedNames, CreatedTime

Output:

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

The following code example shows how to use Get-APSFleetList.

Tools for PowerShell V5

Example 1: This Sample displays details of a fleet

Get-APSFleetList -Name Test

Output:

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
  • For API details, see DescribeFleets in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSImageBuilderList.

Tools for PowerShell V5

Example 1: This Sample displays details of an ImageBuilder

Get-APSImageBuilderList -Name TestImage

Output:

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

The following code example shows how to use Get-APSImageList.

Tools for PowerShell V5

Example 1: This sample displays private AppStream Images

Get-APSImageList -Type PRIVATE | select DisplayName, ImageBuilderName, Visibility, arn

Output:

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
  • For API details, see DescribeImages in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSImagePermission.

Tools for PowerShell V5

Example 1: This sample displays Image permissions on a shared AppStream Image

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

Output:

SharedAccountId AllowFleet AllowImageBuilder --------------- ---------- ----------------- 123456789012 True True

The following code example shows how to use Get-APSSessionList.

Tools for PowerShell V5

Example 1: This sample displays list of sessions to a fleet

Get-APSSessionList -FleetName PowershellFleet -StackName PowershellStack

Output:

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
  • For API details, see DescribeSessions in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSStackList.

Tools for PowerShell V5

Example 1: This sample displays list of AppStream Stack

Get-APSStackList | Select DisplayName, Arn, CreatedTime

Output:

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
  • For API details, see DescribeStacks in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSTagsForResourceList.

Tools for PowerShell V5

Example 1: This sample displays tags on an AppStream resource

Get-APSTagsForResourceList -ResourceArn arn:aws:appstream:us-east-1:123456789012:stack/SessionScriptTest

Output:

Key Value --- ----- StackState Test

The following code example shows how to use Get-APSUsageReportSubscription.

Tools for PowerShell V5

Example 1: This sample displays AppStreamUsageReport configuration details

Get-APSUsageReportSubscription

Output:

LastGeneratedReportDate S3BucketName Schedule SubscriptionErrors ----------------------- ------------ -------- ------------------ 1/1/0001 12:00:00 AM appstream-logs-us-east-1-123456789012-sik1hnxe DAILY {}

The following code example shows how to use Get-APSUser.

Tools for PowerShell V5

Example 1: This Sample displays list of users with enabled status

Get-APSUser -AuthenticationType USERPOOL | Select-Object UserName, AuthenticationType, Enabled

Output:

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
  • For API details, see DescribeUsers in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-APSUserStackAssociation.

Tools for PowerShell V5

Example 1: This sample displays list of users assigned to a stack

Get-APSUserStackAssociation -StackName PowershellStack

Output:

AuthenticationType SendEmailNotification StackName UserName ------------------ --------------------- --------- -------- USERPOOL False PowershellStack TestUser1@lab.com USERPOOL False PowershellStack TestUser2@lab.com