Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Re-connect VM NICs to specific switches after a disconnect?

$
0
0

My objective is to instantly cut off a VM's network access, such as during a crypto attack. I thought I could do this with a script thatdisconnectsthe VM's NICs from the host's virtual switches. This works:

disconnect-vmnetworkadapater -vmname -computername *

For reference, here's the result of a get-vmnetworkadapter:

PS C:\ Get-VMNetworkAdapter -vmname it35fs -computername it30m

Name IsManagementOs VMName SwitchName MacAddress Status IPAddresses
---- -------------- ------ ---------- ---------- ------ -----------
Network Adapter False IT35FS VSW-40 00155D091E00 {Ok} {10.40.9.35}
Network Adapter False IT35FS VSW-30 00155D091E0E {Ok} {10.30.9.35}

My thought was to have the disconnect script write out its own reconnect script as part of its execution. So, it should pull out the host name, VM name, NIC name, and switch...


Viewing all articles
Browse latest Browse all 15370

Trending Articles