第 5 版 (V5) AWS Tools for PowerShell 已發行!
如需有關中斷變更和遷移應用程式的資訊,請參閱遷移主題。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 Tools for PowerShell V5 的 AppStream 2.0 範例
下列程式碼範例示範如何使用 AWS Tools for PowerShell V5 搭配 AppStream 2.0 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 TagResource。
-
以下程式碼範例顯示如何使用 Copy-APSImage。
- PowerShell V5 的工具
-
範例 1:此範例會將映像複製到其他區域
Copy-APSImage -DestinationImageName TestImageCopy -DestinationRegion us-west-2 -SourceImageName Powershell輸出:
TestImageCopy-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet Reference (V5) 中的 CopyImage。
-
以下程式碼範例顯示如何使用 Disable-APSUSer。
- PowerShell V5 的工具
-
範例 1:此範例會停用 USERPOOL 中的 使用者
Disable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com-
如需 API 詳細資訊,請參閱AWS Tools for PowerShell 《 Cmdlet Reference (V5)》中的 DisableUser。
-
以下程式碼範例顯示如何使用 Enable-APSUser。
- PowerShell V5 的工具
-
範例 1:此範例會在 USERPOOL 中啟用已停用的使用者
Enable-APSUser -AuthenticationType USERPOOL -UserName TestUser@lab.com-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 (V5) 中的 EnableUser。
-
以下程式碼範例顯示如何使用 Get-APSAssociatedFleetList。
- PowerShell V5 的工具
-
範例 1:此範例顯示與堆疊相關聯的機群
Get-APSAssociatedFleetList -StackName PowershellStack輸出:
PowershellFleet-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 (V5) 中的 ListAssociatedFleets。
-
以下程式碼範例顯示如何使用 Get-APSAssociatedStackList。
- PowerShell V5 的工具
-
範例 1:此範例顯示與機群相關聯的堆疊
Get-APSAssociatedStackList -FleetName PowershellFleet輸出:
PowershellStack-
如需 API 詳細資訊,請參閱《 Cmdlet 參考》中的 ListAssociatedStacks (V5)。 AWS Tools for PowerShell
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeDirectoryConfigs。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeFleets。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeImageBuilders。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeImages。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeImagePermissions。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 DescribeSessions。
-
以下程式碼範例顯示如何使用 Get-APSStackList。
- PowerShell V5 的工具
-
範例 1:此範例顯示 AppStream Stack 的清單
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 參考 (V5) 中的 DescribeStacks。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 ListTagsForResource。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeUsageReportSubscriptions。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DescribeUsers。
-
以下程式碼範例顯示如何使用 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 Reference (V5)》中的 DescribeUserStackAssociations。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 CreateDirectoryConfig。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 CreateFleet。
-
以下程式碼範例顯示如何使用 New-APSImageBuilder。
- PowerShell V5 的工具
-
範例 1:此範例會在 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 參考 (V5) 中的 CreateImageBuilder。
-
以下程式碼範例顯示如何使用 New-APSImageBuilderStreamingURL。
- PowerShell V5 的工具
-
範例 1:此範例會建立有效 2 小時的 ImageBuilder 串流 URL
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 參考 (V5) 中的 CreateImageBuilderStreamingURL。
-
以下程式碼範例顯示如何使用 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 詳細資訊,請參閱《 Cmdlet 參考》中的 CreateStack (V5)。 AWS Tools for PowerShell
-
以下程式碼範例顯示如何使用 New-APSStreamingURL。
- PowerShell V5 的工具
-
範例 1:此範例會建立 Stack 的串流 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 Reference (V5)》中的 CreateStreamingURL。
-
以下程式碼範例顯示如何使用 New-APSUsageReportSubscription。
- PowerShell V5 的工具
-
範例 1:此範例啟用 AppStream 用量報告
New-APSUsageReportSubscription輸出:
S3BucketName Schedule ------------ -------- appstream-logs-us-east-1-123456789012-sik2hnxe DAILY-
如需 API 詳細資訊,請參閱AWS Tools for PowerShell 《 Cmdlet Reference (V5)》中的 CreateUsageReportSubscription。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 CreateUser。
-
以下程式碼範例顯示如何使用 Register-APSFleet。
- PowerShell V5 的工具
-
範例 1:此範例向堆疊註冊機群
Register-APSFleet -StackName TestStack -FleetName TestFleet -Region us-west-2-
如需 API 詳細資訊,請參閱AWS Tools for PowerShell 《 Cmdlet Reference (V5)》中的 AssociateFleet。
-
以下程式碼範例顯示如何使用 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 Reference (V5)》中的 BatchAssociateUserStack。
-
以下程式碼範例顯示如何使用 Remove-APSDirectoryConfig。
- PowerShell V5 的工具
-
範例 1:此範例會移除 AppStream Directory 組態
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 參考 (V5) 中的 DeleteDirectoryConfig。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 DeleteFleet。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DeleteImage。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DeleteImageBuilder。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DeleteImagePermissions。
-
以下程式碼範例顯示如何使用 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 Reference (V5)》中的 UntagResource。
-
以下程式碼範例顯示如何使用 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 詳細資訊,請參閱《 Cmdlet 參考》中的 DeleteStack (V5)。 AWS Tools for PowerShell
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DeleteUsageReportSubscription。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 DeleteUser。
-
以下程式碼範例顯示如何使用 Revoke-APSSession。
- PowerShell V5 的工具
-
範例 1:此範例會撤銷 AppStream 機群的工作階段
Revoke-APSSession -SessionId 6cd2f9a3-f948-4aa1-8014-8a7dcde14877-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet Reference (V5) 中的 ExpireSession。
-
以下程式碼範例顯示如何使用 Start-APSFleet。
- PowerShell V5 的工具
-
範例 1:此範例會啟動機群
Start-APSFleet -Name PowershellFleet-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 (V5) 中的 StartFleet。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 StartImageBuilder。
-
以下程式碼範例顯示如何使用 Stop-APSFleet。
- PowerShell V5 的工具
-
範例 1:此範例會停止機群
Stop-APSFleet -Name PowershellFleet-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet Reference (V5) 中的 StopFleet。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 StopImageBuilder。
-
以下程式碼範例顯示如何使用 Unregister-APSFleet。
- PowerShell V5 的工具
-
範例 1:此範例會從堆疊取消註冊機群
Unregister-APSFleet -StackName TestStack -FleetName TestFleet -Region us-west-2-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 (V5) 中的 DisassociateFleet。
-
以下程式碼範例顯示如何使用 Unregister-APSUserStackBatch。
- PowerShell V5 的工具
-
範例 1:此範例會從指派的 Stack 移除使用者
Unregister-APSUserStackBatch -UserStackAssociation @{AuthenticationType="USERPOOL";SendEmailNotification=$False;StackName="PowershellStack";UserName="TestUser1@lab.com"}-
如需 API 詳細資訊,請參閱AWS Tools for PowerShell 《 Cmdlet Reference (V5)》中的 BatchDisassociateUserStack。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 UpdateDirectoryConfig。
-
以下程式碼範例顯示如何使用 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 參考 (V5) 中的 UpdateFleet。
-
以下程式碼範例顯示如何使用 Update-APSImagePermission。
- PowerShell V5 的工具
-
範例 1:此範例與其他 帳戶共用 AppStream 映像
Update-APSImagePermission -Name Powershell -SharedAccountId 123456789012 -ImagePermissions_AllowFleet $True -ImagePermissions_AllowImageBuilder $True-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 (V5) 中的 UpdateImagePermissions。
-
以下程式碼範例顯示如何使用 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 Reference (V5) 中的 UpdateStack。
-