Versi 5 (V5) Alat AWS untuk PowerShell telah dirilis!
Untuk informasi tentang mengubah perubahan dan memigrasikan aplikasi Anda, lihat topik https://docs.aws.amazon.com/powershell/v5/userguide/migrating-v5.html migrasi.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
WorkSpaces contoh menggunakan Tools for PowerShell V5
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan Alat AWS untuk PowerShell V5 dengan WorkSpaces.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanApprove-WKSIpRule.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menambahkan aturan ke Grup IP yang ada
$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-
Untuk detail API, lihat AuthorizeIpRules di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanCopy-WKSWorkspaceImage.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menyalin Gambar ruang kerja dengan ID yang ditentukan dari us-west-2 ke wilayah saat ini dengan nama "" CopiedImageTest
Copy-WKSWorkspaceImage -Name CopiedImageTest -SourceRegion us-west-2 -SourceImageId wsi-djfoedhw6Output:
wsi-456abaqfe-
Untuk detail API, lihat CopyWorkspaceImage di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSClientProperty.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan Koneksi Ulang untuk Klien Ruang Kerja
Edit-WKSClientProperty -Region us-west-2 -ClientProperties_ReconnectEnabled "ENABLED" -ResourceId d-123414a369-
Untuk detail API, lihat ModifyClientProperties di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSSelfServicePermission.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan izin layanan mandiri untuk Mengubah jenis komputasi dan Meningkatkan Ukuran Volume untuk Direktori yang ditentukan
Edit-WKSSelfservicePermission -Region us-west-2 -ResourceId d-123454a369 -SelfservicePermissions_ChangeComputeType ENABLED -SelfservicePermissions_IncreaseVolumeSize ENABLED-
Untuk detail API, lihat ModifySelfservicePermissions di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSWorkspaceAccessProperty.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan akses Workspace di Android dan Chrome OS untuk Direktori yang ditentukan
Edit-WKSWorkspaceAccessProperty -Region us-west-2 -ResourceId d-123454a369 -WorkspaceAccessProperties_DeviceTypeAndroid ALLOW -WorkspaceAccessProperties_DeviceTypeChromeOs ALLOW-
Untuk detail API, lihat ModifyWorkspaceAccessProperties di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSWorkspaceCreationProperty.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengaktifkan Akses Internet dan Mode Pemeliharaan menjadi true sebagai nilai default saat membuat Ruang Kerja
Edit-WKSWorkspaceCreationProperty -Region us-west-2 -ResourceId d-123454a369 -WorkspaceCreationProperties_EnableInternetAccess $true -WorkspaceCreationProperties_EnableMaintenanceMode $true-
Untuk detail API, lihat ModifyWorkspaceCreationProperties di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSWorkspaceProperty.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mengubah Properti Mode Berjalan Ruang Kerja menjadi Auto Stop untuk Ruang Kerja yang ditentukan
Edit-WKSWorkspaceProperty -WorkspaceId ws-w361s100v -Region us-west-2 -WorkspaceProperties_RunningMode AUTO_STOP-
Untuk detail API, lihat ModifyWorkspaceProperties di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanEdit-WKSWorkspaceState.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mengubah status Ruang Kerja yang ditentukan menjadi Tersedia
Edit-WKSWorkspaceState -WorkspaceId ws-w361s100v -Region us-west-2 -WorkspaceState AVAILABLE-
Untuk detail API, lihat ModifyWorkspaceState di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSClientProperty.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mendapatkan Properti Klien dari Klien Ruang Kerja untuk Direktori yang ditentukan
Get-WKSClientProperty -ResourceId d-223562a123-
Untuk detail API, lihat DescribeClientProperties di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSIpGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mendapatkan rincian Grup IP yang ditentukan di wilayah yang ditentukan
Get-WKSIpGroup -Region us-east-1 -GroupId wsipg-8m1234v45Output:
GroupDesc GroupId GroupName UserRules --------- ------- --------- --------- wsipg-8m1234v45 TestGroup {Amazon.WorkSpaces.Model.IpRuleItem, Amazon.WorkSpaces.Model.IpRuleItem}-
Untuk detail API, lihat DescribeIpGroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSTag.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mengambil tag untuk Ruang Kerja yang diberikan
Get-WKSTag -WorkspaceId ws-w361s234r -Region us-west-2Output:
Key Value --- ----- auto-delete no purpose Workbench-
Untuk detail API, lihat DescribeTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Mengambil detail semua Anda WorkSpaces ke pipeline.
Get-WKSWorkspaceOutput:
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.WorkspacePropertiesContoh 2: Perintah ini menunjukkan nilai properti anak
WorkSpacePropertiesuntuk ruang kerja dius-west-2wilayah tersebut. Untuk informasi selengkapnya tentang properti turunanWorkSpaceProperties, lihat https://docs.aws.amazon.com/workspaces/latest/api/API_WorkspaceProperties.html.(Get-WKSWorkspace -Region us-west-2 -WorkSpaceId ws-xdaf7hc9s).WorkspacePropertiesOutput:
ComputeTypeName : STANDARD RootVolumeSizeGib : 80 RunningMode : AUTO_STOP RunningModeAutoStopTimeoutInMinutes : 60 UserVolumeSizeGib : 50Contoh 3: Perintah ini menunjukkan nilai properti
RootVolumeSizeGibanakWorkSpacePropertiesuntuk ruang kerja dius-west-2wilayah tersebut. Ukuran volume akar, dalam GiB, adalah 80.(Get-WKSWorkspace -Region us-west-2 -WorkSpaceId ws-xdaf7hc9s).WorkspaceProperties.RootVolumeSizeGibOutput:
80-
Untuk detail API, lihat DescribeWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspaceBundle.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mengambil detail dari semua bundel Workspace di wilayah saat ini
Get-WKSWorkspaceBundleOutput:
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-
Untuk detail API, lihat DescribeWorkspaceBundles di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspaceDirectory.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini mencantumkan detail direktori untuk direktori terdaftar
Get-WKSWorkspaceDirectoryOutput:
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-
Untuk detail API, lihat DescribeWorkspaceDirectories di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspaceImage.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mengambil semua detail dari semua gambar di wilayah
Get-WKSWorkspaceImageOutput:
Description :This image is copied from another image ErrorCode : ErrorMessage : ImageId : wsi-345ahdjgo Name : CopiedImageTest OperatingSystem : Amazon.WorkSpaces.Model.OperatingSystem RequiredTenancy : DEFAULT State : AVAILABLE-
Untuk detail API, lihat DescribeWorkspaceImages di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspaceSnapshot.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menunjukkan stempel waktu dari snapshot terbaru yang dibuat untuk Ruang Kerja yang ditentukan
Get-WKSWorkspaceSnapshot -WorkspaceId ws-w361s100vOutput:
RebuildSnapshots RestoreSnapshots ---------------- ---------------- {Amazon.WorkSpaces.Model.Snapshot} {Amazon.WorkSpaces.Model.Snapshot}-
Untuk detail API, lihat DescribeWorkspaceSnapshots di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanGet-WKSWorkspacesConnectionStatus.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mengambil status koneksi untuk Ruang Kerja yang ditentukan
Get-WKSWorkspacesConnectionStatus -WorkspaceId ws-w123s234r-
Untuk detail API, lihat DescribeWorkspacesConnectionStatus di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-WKSIpGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini membuat grup Ip kosong bernama FreshEmptyIpGroup
New-WKSIpGroup -GroupName "FreshNewIPGroup"Output:
wsipg-w45rty4ty-
Untuk detail API, lihat CreateIpGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-WKSTag.
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini menambahkan tag baru ke ruang kerja bernama
ws-wsname. Tag memiliki kunci “Nama”, dan nilai kunci dariAWS_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 $tagContoh 2: Contoh ini menambahkan beberapa tag ke ruang kerja bernama
ws-wsname. Satu tag memiliki kunci “Nama” dan nilai kunciAWS_Workspace; tag lainnya memiliki kunci tag “Stage” dan nilai kunci “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-
Untuk detail API, lihat CreateTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanNew-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Buat WorkSpace untuk bundel, direktori, dan pengguna yang disediakan.
New-WKSWorkspace -Workspace @{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME"}Contoh 2: Contoh ini membuat beberapa WorkSpaces
New-WKSWorkspace -Workspace @{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME_1"},@{"BundleID" = "wsb-1a2b3c4d"; "DirectoryId" = "d-1a2b3c4d"; "UserName" = "USERNAME_2"}-
Untuk detail API, lihat CreateWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-WKSIpGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mendaftarkan Grup IP yang ditentukan dengan Direktori yang ditentukan
Register-WKSIpGroup -GroupId wsipg-23ahsdres -DirectoryId d-123412e123-
Untuk detail API, lihat AssociateIpGroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRegister-WKSWorkspaceDirectory.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini mendaftarkan direktori yang ditentukan untuk Layanan Ruang Kerja
Register-WKSWorkspaceDirectory -DirectoryId d-123412a123 -EnableWorkDoc $false-
Untuk detail API, lihat RegisterWorkspaceDirectory di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-WKSIpGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini menghapus Grup IP yang ditentukan
Remove-WKSIpGroup -GroupId wsipg-32fhgtredOutput:
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-
Untuk detail API, lihat DeleteIpGroup di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-WKSTag.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini menghapus tag yang terkait dengan Workspace
Remove-WKSTag -ResourceId ws-w10b3abcd -TagKey "Type"Output:
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-
Untuk detail API, lihat DeleteTags di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRemove-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Mengakhiri beberapa WorkSpaces. Penggunaan sakelar -Force menghentikan cmdlet dari meminta konfirmasi.
Remove-WKSWorkspace -WorkspaceId "ws-1a2b3c4d5","ws-6a7b8c9d0" -ForceContoh 2: Mengambil koleksi semua ID Anda WorkSpaces dan menyalurkan ID ke WorkSpaceId parameter - dari Remove-WKSWorkspace, mengakhiri semua. WorkSpaces Cmdlet akan meminta sebelum masing-masing WorkSpace dihentikan. Untuk menekan prompt konfirmasi tambahkan sakelar -Force.
Get-WKSWorkspaces | Remove-WKSWorkspaceContoh 3: Contoh ini menunjukkan cara meneruskan TerminateRequest objek yang mendefinisikan yang WorkSpaces akan dihentikan. Cmdlet akan meminta konfirmasi sebelum melanjutkan, kecuali parameter sakelar -Force juga ditentukan.
$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-
Untuk detail API, lihat TerminateWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanReset-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Membangun kembali yang ditentukan WorkSpace.
Reset-WKSWorkspace -WorkspaceId "ws-1a2b3c4d"Contoh 2: Mengambil koleksi semua ID Anda WorkSpaces dan menyalurkan ID ke WorkSpaceId parameter - Reset-WKSWorkspace, WorkSpaces menyebabkan itu dibangun kembali.
Get-WKSWorkspaces | Reset-WKSWorkspace-
Untuk detail API, lihat RebuildWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanRestart-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Mem-boot ulang yang ditentukan WorkSpace.
Restart-WKSWorkspace -WorkspaceId "ws-1a2b3c4d"Contoh 2: Mem-boot ulang beberapa WorkSpaces.
Restart-WKSWorkspace -WorkspaceId "ws-1a2b3c4d","ws-5a6b7c8d"Contoh 3: Mengambil koleksi semua ID Anda WorkSpaces dan menyalurkan ke WorkSpaceId parameter - Restart-WKSWorkspace, menyebabkan dihidup WorkSpaces kan ulang.
Get-WKSWorkspaces | Restart-WKSWorkspace-
Untuk detail API, lihat RebootWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanStop-WKSWorkspace.
- Alat untuk PowerShell V5
-
Contoh 1: Menghentikan beberapa WorkSpaces.
Stop-WKSWorkspace -WorkspaceId "ws-1a2b3c4d5","ws-6a7b8c9d0"Contoh 2: Mengambil koleksi semua ID Anda WorkSpaces dan menyalurkan ID ke WorkSpaceId parameter - yang Stop-WKSWorkspace WorkSpaces menyebabkan dihentikan.
Get-WKSWorkspaces | Stop-WKSWorkspaceContoh 3: Contoh ini menunjukkan cara meneruskan StopRequest objek yang mendefinisikan WorkSpaces untuk dihentikan.
$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-
Untuk detail API, lihat StopWorkspaces di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-
Contoh kode berikut menunjukkan cara menggunakanUnregister-WKSIpGroup.
- Alat untuk PowerShell V5
-
Contoh 1: Sampel ini membatalkan pendaftaran Grup IP yang ditentukan dari Direktori yang ditentukan
Unregister-WKSIpGroup -GroupId wsipg-12abcdphq -DirectoryId d-123454b123-
Untuk detail API, lihat DisassociateIpGroups di Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-