托管磁盘创建错误 [英] Managed Disk Creation Error
问题描述
Hi All,
我正在尝试使用PowerShell和托管磁盘创建虚拟机,默认情况下,其创建高级磁盘和磁盘名称具有独特的优势.
I am trying to create a VM using PowerShell and Managed disk and by default, its creating a premium disk and disk name has unique sting.
我正在尝试使用Set-AzureRmVMOSDisk命令将其设置为标准"磁盘,并从磁盘名称中删除唯一字符串,但是此命令不适用于New-AzureRmVMConfig命令.
I am trying Set-AzureRmVMOSDisk command to set it to Standard disk and remove the unique string from disk name but this command is not working with New-AzureRmVMConfig command.
代码:
$ vmConfig = New-AzureRmVMConfig -VMName $ vmName -VMSize Standard_A1 | Set-AzureRmVMOSDisk -CreateOption fromImage -VM $ vmName -名称$ vmdiskname -StorageAccountType"Standard_LRS"; -Windows || Set-AzureRmVMOperatingSystem -Windows -ComputerName $ vmName -Credential $ cred -ProvisionVMAgent -EnableAutoUpdate | Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer-提供WindowsServer -Skus 2016-Datacenter -Version最新| Add-AzureRmVMNetworkInterface -Id $ nic.Id&p
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_A1 | Set-AzureRmVMOSDisk -CreateOption fromImage -VM $vmName -Name $vmdiskname -StorageAccountType "Standard_LRS" -Windows | Set-AzureRmVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate| Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2016-Datacenter -Version latest | Add-AzureRmVMNetworkInterface -Id $nic.Id
错误:
Set-AzureRmVMOSDisk : Cannot bind parameter 'VM'. Cannot convert the "VM01" value of type "System.String" to type "Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine".
您能否建议我如何创建具有标准磁盘且磁盘名称中没有唯一字符串的托管磁盘VM?
Can you please suggest how can I create managed disk VM with standard disk and without unique string in disk name ?
有可能还是我只需要使用JSON模板?
Is it possible or I need to use JSON template only ?
推荐答案
svaghela,
Hi svaghela,
看起来-VM参数导致了此错误.在这种情况下,此参数不能为字符串.
It looks like the -VM parameter is causing this error. This parameter can not be a string in this case.
-VM参数应使用
The -VM parameter should use the
vmConfig变量来代替,该变量存储 New-AzureRmVMConfig命令.
vmConfig variable instead which stores the New-AzureRmVMConfig command.
作为参考,我建议以下有关如何使用Set-AzureRmVMOSDisk命令的指南:
For your reference, I would recommend the following guide on how the Set-AzureRmVMOSDisk command can be used: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/set-azurermvmosdisk?view=azurermps-6.12.0
这篇关于托管磁盘创建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!