Last active
October 23, 2019 01:11
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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