0

I have a problem with a Hyper-V internal network adapter and my external network (Intel Wi-Fi). Sometimes after starting a VM I lose access to my network shares both from my LAN and from VM itself (I get connection timeout, like port is closed). The firewall is configured manually with gpedit.msc to allow TCP/UDP trafic from both LAN and VM subnets (I can reach postgres fine from both LAN and VM).

I found a workaround, by disabling and re-enabling this File and Printer Sharing for Microsoft Networks it seems to work (I need to do it on both adapters to restore connectivity for LAN and VM respectively).

Question: Is there any PowerShell/WMI/VBScript command to automate this? I found Set-NetAdapter but it doesn't seem to have any relevant options.

Adapter option

  • Please note that superuser.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?. – DavidPostill Dec 18 '18 at 20:49
  • @DavidPostill I don't know if the API to do that exists or not and I am just looking for a hint (registry path, name of PowerShell cmdlet, WMI path, etc..). How can I provide a code sample if I don't know if it's even possible? – Nazar554 Dec 18 '18 at 21:01
  • You do your own research first. Then ask a question presenting your research and where you stuck implementing it yourself. – DavidPostill Dec 18 '18 at 21:03
  • @DavidPostill Duh it's Enable-NetAdapterBinding/Disable-NetAdapterBinding – Nazar554 Dec 18 '18 at 21:09
  • Reopened so you can self answer – DavidPostill Dec 18 '18 at 21:11
0

It can be done using Disable-NetAdapterBinding/Enable-NetAdapterBinding

Disable-NetAdapterBinding -Name "Your network adapter name" -DisplayName "File and Printer Sharing for Microsoft Networks"
Enable-NetAdapterBinding -Name "Your network adapter name" -DisplayName "File and Printer Sharing for Microsoft Networks"

Alternatively you can use -ComponentID ms_server instead of -DisplayName "..."

To get all adapters and available bindings use Get-NetAdapterBinding

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.