【问题标题】:New-AzureRmVM : Parameter set cannot be resolved using the specified named parametersNew-AzureRmVM:无法使用指定的命名参数解析参数集
【发布时间】:2018-06-05 01:58:51
【问题描述】:

我是 Powershell 新手,我正在运行以下脚本并收到主题行中提到的错误:

$LocationName = "West Europe"
$VNet_ResourceGroupName = "Mydeveloper_resource_group"
$VM_ResourceGroupName = "MyDeveloperResourceGroup"
$PublicIpAddress = "[]"
$PrivateIpAddress = "10.199.120.30" 
$VirtualNetworkName = "developer_vnet"
$SubnetName = "MySubnet"
$SubnetId = "/subscriptions/....../resourceGroups/developer_resource_group/providers/Microsoft.Network/virtualNetworks/developer_vnet/subnets/MySubnet"
$VMName = "AWE4DVM022"
$VMSize = "Standard_D4s_v3"
$AllocationMethod = "Static"
$ImageId = "/subscriptions/................................./resourceGroups/MyIMAGELIBRARY/providers/Microsoft.Compute/images/developer-desktop-image-...................." 

$cred = Get-Credential -Message "Type the name and password of the local administrator account."

$nic = New-AzureRmNetworkInterface -Name TestNIC -ResourceGroupName $VM_ResourceGroupName -Location $LocationName -SubnetId $SubnetId -PrivateIpAddress $PrivateIpAddress

$vm = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize

$vm = Set-AzureRmVMOperatingSystem -VM $vm -Linux -ComputerName $VMName -Credential $cred

$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id 

New-AzureRmVM -ResourceGroupName $VM_ResourceGroupName -ImageName $ImageId -VM $vm

【问题讨论】:

  • 欢迎来到 Stack Overflow!请拨打tour。您可能想稍微具体说明您的问题:您要实现什么目标?哪一行抛出错误?

标签: powershell azure azure-powershell


【解决方案1】:

Powershell 有这个参数集的概念。当您调用使用参数集的脚本、函数或命令行开关时(如 New-AzureRMVM 所做的那样),您不能为不同集中的参数传递参数。例如,New-AzureRmVM has three parameters setsResourceGroupName 在参数集 1、2 和 3 中。ImageName 在参数集 1 中,VM 在参数集 2 中。Powershell 无法确定要使用的集,因为 ImageName 为一当VM 在另一个时设置。

【讨论】:

    猜你喜欢
    • 2019-09-02
    • 2018-08-29
    • 1970-01-01
    • 2022-11-16
    • 2019-04-05
    • 2014-09-05
    • 2020-07-23
    • 2018-05-13
    • 2015-10-12
    相关资源
    最近更新 更多