Hi everyone!
How can I make in PS (PowerShell) the image action?

Select the virtual switch for the VM.
Thanks.
Hi everyone!
How can I make in PS (PowerShell) the image action?

Select the virtual switch for the VM.
Thanks.
Use
Connect-VMNetworkAdapter -vmname <VMName> -Name <NetworkAdapterName> -switchname <Switchname>
So for a VM called test with a NIC called NIC1 connecting to ExternalNetwork
Connect-VMNetworkAdapter -vmname test -Name NIC1 -switchname ExternalNetwork
If you don’t know the name of the network adapter use;
Get-VMNetworkAdapter -vmname test
to get a list of adapters for that VM
Hi,
If you would like to connect a virtual switch to a VM by PowerShell, you could use Connect-VMNetworkAdapter command.
For your reference: https://docs.microsoft.com/en-us/powershell/module/hyper-v/connect-vmnetworkadapter?view=windowsserver2019-ps
If you would like to disconnect a virtual switch by PowerShell, you could use Disconnect-VMNetworkAdapter command.
For your reference: https://docs.microsoft.com/en-us/powershell/module/hyper-v/disconnect-vmnetworkadapter?view=windowsserver2019-ps
If you would like to get virtual switches from the Hyper-V host, you could use Get-VMSwitch command.
For your reference: https://docs.microsoft.com/en-us/powershell/module/hyper-v/get-vmswitch?view=windowsserver2019-ps
If you would like to create a new switch, you could use New-VMSwitch command.
For your reference: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-switch-for-hyper-v-virtual-machines#create-a-virtual-switch-by-using-windows-powershell
If you would like to create a new VM with specific switch, you could use New-VM -Name <Name> -MemoryStartupBytes <Memory> -BootDevice <BootDevice> -VHDPath <VHDPath> -Path <Path> -Generation <Generation> -Switch <SwitchName>
For your reference: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-machine-in-hyper-v#create-a-virtual-machine-by-using-windows-powershell
Hope above information could help you.
Thanks,
If the Answer is helpful, please click "Accept Answer" and upvote it. Thanks.
8 people are following this question.