我是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
答案 0 :(得分:2)
Powershell has this concept of parameter sets. When you call a script, function, or commandlet that uses parameter sets (like New-AzureRMVM does), you can't pass parameters for arguments in different sets. For example, New-AzureRmVM has three parameters sets. ResourceGroupName
is in parameter sets 1, 2, and 3. ImageName
is in parameter set 1, and VM
is in parameter set 2. Powershell can't figure out what set to use because ImageName
is on one set while VM
is in another.