Skip to content

Instantly share code, notes, and snippets.

@marxangels
Last active October 23, 2019 01:11
Show Gist options
  • Save marxangels/e859a4df0f73a2a134bbb7f1d4b0ac52 to your computer and use it in GitHub Desktop.
Save marxangels/e859a4df0f73a2a134bbb7f1d4b0ac52 to your computer and use it in GitHub Desktop.
How to fix ICS (Windows Internet Connection Sharing) not working after reboot? Just reset ICS manually, or do it by PowerShell.
# Reset Windows Internet Connection Sharing by PowerShell.
# PowerShell.exe -ExecutionPolicy Bypass C:\Path\to\ics-reset.ps1
$module = New-Object -ComObject HNetCfg.HNetShare
$list = New-Object System.Collections.Generic.List[System.Object]
foreach( $connection in $module.EnumEveryConnection ){
$config = $module.INetSharingConfigurationForINetConnection( $connection )
if( $config.SharingEnabled -eq 1 ){
$type = $config.SharingConnectionType
$list.Add( @($type,$config) )
$config.DisableSharing( )
}
}
foreach( $array in $list ){
$array[1].EnableSharing($array[0])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment