关于适用于PowerShell的AWS工具-创建工作区

问题描述

我希望生活顺利。我正在尝试通过PowerShell为用户帐户创建AWS Workspaces。我已经熟悉通过AWS CLI执行此操作的过程,并且使用JSON模板取得了巨大成功。但是,在PowerShell中执行此操作时,我遇到了麻烦。我的总体目标是使创建WorkSpaces的过程更具可编程性。当前行:

New-WKSWorkspace -Workspace @{"BundleId" = "xxxxxx"; "UserName" = "xxxxxx"; "DirectoryId" = "xxxxxxx";} 

此行执行得很好,并根据输入的参数创建工作区。我的问题是,在创建工作空间时,需要在初始阶段设置“ VolumeEncryptionKey”。但是,在阅读适用于PowerShell的AWS工具文档并运行以下命令时:

Get-Command Get-WKSWorkspace -ShowCommandInfo

我找不到“ VolumeEncryptionKey”的参数,这导致了问题。我以为可以通过以下方式设置值:

(Get-WKSWorkspace -WorkspaceId xxxxxxxxxx).VolumeEncryptionKey

但这并没有真正的帮助,而且似乎也没有“ Set-WKSWorkspace”命令。以前有没有人有过使用适用于PowerShell的AWS工具构建工作区的经验?请让我知道。

因此,我尝试在之前执行该命令:

New-WKSWorkspace -Workspace @{ "VolumeEncryptionKey" = "xxxxxx"; "BundleId" = "xxxxxx"; "UserName" = "xxxxxx"; "DirectoryId" = "xxxxxxx";}

但是会产生错误

enter image description here

enter image description here

这是我使用的JSON骨架,效果非常好:

{
"Workspaces": [
  {
    "DirectoryId": "xxxxxxxxxxx","UserName": "xxxxxxxx","BundleId": "xxxxxxxx","VolumeEncryptionKey": "xxxxxxxxxxxx","UserVolumeEncryptionEnabled": true,"RootVolumeEncryptionEnabled": true,"WorkspaceProperties": {
      "RunningMode": "ALWAYS_ON","RootVolumeSizeGib": 175,"UserVolumeSizeGib": 100,"ComputeTypeName": "PERFORMANCE"
    },"Tags": [
      {
        "Key": "xxxxxxx","Value": "xxxxxxxxxxx"
      }
    ]
  }
]

}

游戏计划是尝试通过适用于PowerShell的AWS工具运行它。

解决方法

从对the documentation的粗读中可以得出结论,您需要将其包括在-Workspace参数中:

New-WKSWorkspace -Workspace @{"VolumeEncryptionKey" = "<VEK goes here>"; "BundleId" = "xxxxxx"; "UserName" = "xxxxxx"; "DirectoryId" = "xxxxxxx"; }