This PowerShell module provides simple functions to control Windows Internet Connection Sharing (ICS) from command line.
The module includes three functions:
Set-IcsGet-IcsDisable-Ics
All functions are required to run with administrative rights and works with both Powershell Desktop (v5.1) and Core editions. PowerShell execution policy must be set to RemoteSigned, Unrestricted or Bypass.
The module has been tested on Windows 10.
The module can now be downloaded from PowerShell Gallery using PowerShell command line:
Install-Module -Name PSInternetConnectionSharing
or manually downloaded here on GitHub:
Download the module files (extensions .psm1 and .psd1) and then create a new module folder in your PSModulePath. Default PSModulePath is:
- for a specific user:
%USERPROFILE%\Documents\WindowsPowerShell\Modules\ - for all users:
%ProgramFiles%\WindowsPowerShell\Modules\
Name the new module folder exactly as the filename without the extension, in this case PSInternetConnectionSharing, and then copy the downloaded module files to that folder. PowerShell will now automatically find the module and its functions.
Set-Ics [-PublicConnectionName] <string> [-PrivateConnectionName] <string> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-Ics lets you share the internet connection of a network connection (called the public connection) with another network connection (called the private connection). The specified network connections must exist beforehand. In order to be able to set ICS, the function will first disable ICS for any existing network connections.
The name of the network connection that internet connection will be shared from.
The name of the network connection that internet connection will be shared with.
If this parameter is specified Set-Ics returns an output with the set connections. Optional. By default Set-Ics does not generate any output.
Shows what would happen if the function runs. The function is not run.
Prompts you for confirmation before each change the function makes.
Set-Ics -PublicConnectionName Ethernet -PrivateConnectionName 'VM Host-Only Network'
Set-Ics Ethernet 'VM Host-Only Network'
Set-Ics Ethernet 'VM Host-Only Network' -PassThru
Get-Ics [[-ConnectionNames] <string[]>] [-HideDisabled] [<CommonParameters>]
Retrieves status of Internet Connection Sharing (ICS) for all network connections, or optionally for the specified network connections. Output is in the form of a PSCustomObject.
Name(s) of the network connection(s) to get ICS status for. Optional.
By default Get-Ics lists ICS status for all network connections if parameter ConnectionNames is omitted. When adding parameter HideDisabled, Get-Ics only lists connections where ICS is enabled.
Get-Ics
Get-Ics -HideDisabled
Get-Ics -ConnectionNames Ethernet, Ethernet2, 'VM Host-Only Network'
Get-Ics Ethernet, Ethernet2, 'VM Host-Only Network'
Disable-Ics [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Checks for if ICS is enabled for any network connection and, if so, disables ICS for those connections.
If this parameter is specified Disable-Ics returns an output with the disabled connections. Optional. By default Disable-Ics does not generate any output.
Shows what would happen if the function runs. The function is not run.
Prompts you for confirmation before each change the function makes.
Disable-Ics
Disable-Ics -PassThru