无法使用 Powewshell 创建 AWS ClientVPNEndPoint

Unable to create AWS ClientVPNEndPoint with Powewshell

提问人:Philippe sillon 提问时间:11/17/2023 最后编辑:Philippe sillon 更新时间:11/17/2023 访问量:21

问:

我想在 Windows 10 专业版上使用 Powershell 模块 AWSPowerShell.NetCore 版本 4.1.385 创建 ClientVPNEndPoint。

当我运行这个:

    $serverCertificat = Get-ACMCertificateList | where-object { $_.DomainName -eq "server" } 
    $clientCertificat = Get-ACMCertificateList | where-object { $_.DomainName -eq "client1.domain.tld" } 

    $Authentication = new-object Amazon.EC2.Model.ClientVpnAuthenticationRequest
    $Authentication.Type = Amazon.EC2.ClientVpnAuthenticationType.CertificateAuthentication
    $Authentication.MutualAuthentication = new-object Amazon.EC2.Model.CertificateAuthenticationRequest
    $Authentication.MutualAuthentication.ClientRootCertificateChainArn = $clientCertificat.CertificateArn
    
    New-EC2ClientVpnEndpoint -ClientCidrBlock "10.0.0.0/22" `
                            -ServerCertificateArn $serverCertificat.CertificateArn `
                            -AuthenticationOption @($Authentication) `
                            -DnsServer @("172.31.43.131","172.31.30.194") `
                            -vpcid (Get-EC2VPC).VpcId `
                            -ConnectionLogOptions_Enabled $false

...我收到以下错误

Amazon.EC2.ClientVpnAuthenticationType.CertificateAuthentication: 
Line |
   8 |  … tion.Type = Amazon.EC2.ClientVpnAuthenticationType.CertificateAuthent …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'Amazon.EC2.ClientVpnAuthenticationType.CertificateAuthentication' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
New-EC2ClientVpnEndpoint: 
Line |
  12 |  New-EC2ClientVpnEndpoint -ClientCidrBlock "10.0.0.0/22" `
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Authentication type is required but is missing in the request

注1:PS功能文档链接:https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2ClientVpnEndpoint.html

注2:我已经检查了PS模块dll,更具体地说,在没有任何帮助的情况下检查了Amazon.EC2.ClientVpnAuthenticationType

using System;
using Amazon.Runtime;

namespace Amazon.EC2
{
    // Token: 0x02000032 RID: 50
    public class ClientVpnAuthenticationType : ConstantClass
    {
        // Token: 0x060005C6 RID: 1478 RVA: 0x00012B61 File Offset: 0x00010D61
        public ClientVpnAuthenticationType(string value) : base(value)
        {
        }

        // Token: 0x060005C7 RID: 1479 RVA: 0x00012B6A File Offset: 0x00010D6A
        public static ClientVpnAuthenticationType FindValue(string value)
        {
            return ConstantClass.FindValue<ClientVpnAuthenticationType>(value);
        }

        // Token: 0x060005C8 RID: 1480 RVA: 0x00012B72 File Offset: 0x00010D72
        public static implicit operator ClientVpnAuthenticationType(string value)
        {
            return ClientVpnAuthenticationType.FindValue(value);
        }

        // Token: 0x040000B5 RID: 181
        public static readonly ClientVpnAuthenticationType CertificateAuthentication = new ClientVpnAuthenticationType("certificate-authentication");

        // Token: 0x040000B6 RID: 182
        public static readonly ClientVpnAuthenticationType DirectoryServiceAuthentication = new ClientVpnAuthenticationType("directory-service-authentication");

        // Token: 0x040000B7 RID: 183
        public static readonly ClientVpnAuthenticationType FederatedAuthentication = new ClientVpnAuthenticationType("federated-authentication");
    }
}
Amazon-Web-Services PowerShell VPN

评论

0赞 jdweng 11/18/2023
缺少选项 -ServerCertificateArn。请参阅:docs.aws.amazon.com/powershell/latest/reference/items/...docs.aws.amazon.com/acm/latest/userguide/acm-overview.html
0赞 Philippe sillon 11/19/2023
你是什么意思?ServerCertificateArn 参数是调用函数 New-EC2ClientVpnEndpoint 时的第二个参数...
0赞 jdweng 11/19/2023
你是对的。正在使用的 Net 版本。看起来您可能有旧版本的 Net。在版本 4.5 中,您的类型被定义为静态方法。请参阅:docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/...

答: 暂无答案