[英]how to set Set-VMFirmware on a single line in powershell
i am trying to make a small c# application to create my Hyper V VM's but i has got a problem with powershell in c# so i just running every powershell cmdlet using cmd.exe 我正在尝试制作一个小型C#应用程序来创建我的Hyper V VM,但是我在C#中遇到了Powershell问题,所以我只使用cmd.exe运行每个powershell cmdlet。
but now i cant get how to set dvddrive as firstbootdevice in generation 2 virtual machine in just one line for powershell script i use 但是现在我无法在第二行虚拟机中将dvddrive设置为第二代虚拟机中的firstbootdevice
$VMNAME= "SQL3"
$VMDVD = Get-VMDvdDrive -VMName $VMNAME
Set-VMFirmware -VMName $VMNAME -FirstBootDevice $VMDVD
but how can i do it in a single line 但是我怎么能单行
通常,任何变量引用都可以由子表达式( $()
)代替:
Set-VMFirmware -VMName "SQL3" -FirstBootDevice $(Get-VMDvdDrive -VMName "SQL3")
If you have multiple DVD drives and know the ISO file 如果您有多个DVD驱动器并且知道ISO文件
$DvdBootDrive = Get-VMDvdDrive -VMName $VmName | where {$_.Path -Like "*AutoInstall.iso*" }
Set-VMFirmware -VMName $VmName -FirstBootDevice $DvdBootDrive
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.