If there is only one ip address on a card we need to force it to be an array. Otherwise powershell may treat it as a property.
Stop-Vm with force parameter to ensure that powershell prompts will not appear
This commit is contained in:
parent
730c6217ad
commit
9cf8b18e09
|
@ -15,7 +15,7 @@ if ($HostVMAdapter){
|
||||||
if ($HostNetAdapter){
|
if ($HostNetAdapter){
|
||||||
$HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE' AND InterfaceIndex=$($HostNetAdapter.ifIndex)")
|
$HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE' AND InterfaceIndex=$($HostNetAdapter.ifIndex)")
|
||||||
if ($HostNetAdapterConfiguration){
|
if ($HostNetAdapterConfiguration){
|
||||||
return $HostNetAdapterConfiguration.IpAddress[$addressIndex]
|
return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ func TurnOff(vmName string) error {
|
||||||
param([string]$vmName)
|
param([string]$vmName)
|
||||||
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
|
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
|
||||||
if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
|
if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
|
||||||
Stop-VM -Name $vmName -TurnOff -Confirm:$false
|
Stop-VM -Name $vmName -TurnOff -Confirm:$false -Force
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ func ShutDown(vmName string) error {
|
||||||
param([string]$vmName)
|
param([string]$vmName)
|
||||||
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
|
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
|
||||||
if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
|
if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
|
||||||
Stop-VM -Name $vmName -Confirm:$false
|
Stop-VM -Name $vmName -Confirm:$false -Force
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue