Powershell – Windows 8.1 Hyper-V network adapter is set to public and won’t save as private

powershellwindows-8.1

I have a collection of Windows 8.1 machines that run Hyper-V for unit testing. We often use PowerShell to script changes to these systems to ease our administration. However, we've been having trouble enabling powershell remoting on these machines.

We run the following command on these machines to attempt powershell remoting enabling

Enable-PSRemoting -force

But we always get the following error:

WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.

The network adapters Are as follows:

Name             : Network  2
InterfaceAlias   : vEthernet (Broadcom NetXtreme Gigabit Ethernet)
InterfaceIndex   : 13
NetworkCategory  : Private
IPv4Connectivity : Internet
IPv6Connectivity : LocalNetwork

Name             : Unidentified network
InterfaceAlias   : vEthernet (Windows Phone Emulator Internal Switch)
InterfaceIndex   : 10
NetworkCategory  : Public
IPv4Connectivity : NoTraffic
IPv6Connectivity : NoTraffic

I tried running the following scripts to set the unidentified network to be private

Set-NetConnectionProfile -name "Network  2" -NetworkCategory private
Set-NetConnectionProfile -name "Unidentified Network" -NetworkCategory private 

However these scripts work for the duration of the machine's uptime, but when the machine reboots, the Unidentified network reverts back to the public.

Why is this resetting, and how can I get the scripted change to persist?

Thanks!

Best Answer

You can exclude certain nics from NLA (Network Location Awareness). Very common to do this in VMware workstation scenarios since the VMware nics always end up as unidentified/public. Here's how:

  1. Navigate to:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
  2. You will find enumerated keys like 0000, 0001, 0002 and so on.
  3. Expend them one by one and look for DriverDesc REG_SZ value data.
  4. In the same registry key where you found the name of the nic to exclude (DriverDesc value), create another new DWORD Value, name it *NdisDeviceType (it Case Sensitive!!). Double click on this value and in "Value Data" field put 1 as Decimal data

(snipped from) http://www.petri.co.il/forums/showthread.php?t=45181

Related Topic