Enable or disable remote Windows 10 ethernet interface from HA?

So I control startup and shutdown of a few windows machines in my home. But, one unique machine has dual ethernets, one on local net and one connected to a hardware vpn. I control the hardware vpn via SNMP to shut it down by shutting down POE on the port. This causes some DNS oddness and slow loading pages after shutdown. The simple fix, if I am home, is to shut down the ethernet interface in windows. My vpn power control will react depending on me being home or not during working hours, but the ethernet port on the pc will not.

I have found that with this netsh command I can enable or disable the port:

netsh interface set interface “xxxx” DISABLED

But, it has to be run with admin permissions and I have not figured a way to send the command from HA.

I would like to roll this into the automation that turns my vpn on or off.

Anyone out there got any ideas? I am really kind of stuck here.

Thanks Matt

You can use Hass Agent to trigger scripts on a windows box. If you already have a script that works you’re almost done…

So, I have it working… I am a fan of command line switches because the are consistent across platforms.

I enabled windows 10 included Openssh server, used my servers public key and enabled key based login.

This is slick and smooth.

- switch:
    name: i7xxxeth
    command_on: 'ssh -i /config/.ssh/id_rsa -F /config/.ssh/config [email protected] netsh interface set interface xxx admin=ENABLE'
    command_off: 'ssh -i /config/.ssh/id_rsa -F /config/.ssh/config [email protected] netsh interface set interface xxx admin=DISABLED'
1 Like

I will have to look into this method as well. But, working for now.