Fixing Windows 10 Version 1607 Internet Sharing

Note that this bug appears to have been fixed in the now current release of Windows 10 (1709, Fall Creators Update, including build 16299). The script below also no longer works in this form.

Since Internet Sharing stops working after a reboot (not just during) with the current version of Windows 10, a Scheduled Task is necessary to restart Internet Sharing at boot.

Use this script to start Internet Sharing.

param(
 $sPublicAdapterName,
 $sPrivateAdapterName
)

if (!$sPrivateAdapterName) {
 Write-Host
"EnableSharing.ps1 sPublicAdapterName sPrivateAdapterName"
 return
}#if

# Constants
$public = 0
$private = 1

Write-Host "Creating netshare object..."
$netshare = New-Object -ComObject HNetCfg.HNetShare

Write-Host "Getting public adapter..."
$publicprops = $netshare.EnumEveryConnection | Where-Object {
 
$netshare.NetConnectionProps($_).Name -eq $sPublicAdapterName
}#foreach
$publicadapter = $netshare.INetSharingConfigurationForINetConnection($publicprops)
$publicadapter | more

Write-Host "Getting private adapter..."
$privateprops = $netshare.EnumEveryConnection | Where-Object {
 
$netshare.NetConnectionProps($_).Name -eq $sPrivateAdapterName
}#foreach
$privateadapter = $netshare.INetSharingConfigurationForINetConnection($privateprops)
$privateadapter | more

Write-Host "Disabling public sharing for public adapter..."
$publicadapter.DisableSharing()
$publicadapter | more

Write-Host "Disabling private sharing for private adapter..."
$privateadapter.DisableSharing()
$privateadapter | more

Write-Host "Enabling public sharing for public adapter...."
$publicadapter.EnableSharing($public)
$publicadapter | more

Write-Host "Enabling private sharing for private adapter...."
$privateadapter.EnableSharing($private)
$privateadapter | more

# Clean up
Remove-Variable netshare

End script. Note that the exact order of disabling and enabling sharing does matter. (Trust me.)

Make sure your adapter names do not contain brackets or, possibly, other special characters. (Rename them if necessary.)

Use a batch file containing the below line to start it from the Task Scheduler.

powershell.exe -Command c:\Windows\Scripts\EnableSharing.ps1 PublicAdapter PrivateAdapter

PublicAdapter and PrivateAdapter are the two adapters. (PublicAdapter is the one connected to the Internet. PrivateAdapter is the one connected to your network.)

 © Andrew Brehm 2016