This PowerShell module provides simple functions to control Windows Internet Connection Sharing (ICS) from command line.
The module includes three functions:
Set-Ics
Get-Ics
Disable-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 object representing 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[]>] [-AllConnections] [<CommonParameters>]
Lists network connections where ICS is enabled, or optionally ICS status for the specified network connections. Output is a PSCustomObject representing the connections.
Name(s) of the network connection(s) to get ICS status for. Optional.
If parameter ConnectionNames is omitted, Get-Ics
by default only lists network connections where ICS is enabled. To list ICS status for all network connections, add the switch parameter AllConnections.
Cannot be combined with parameter ConnectionNames.
Get-Ics
Get-Ics -AllConnections
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 object representing 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