Set NetConnectionProfile - PowerShell


Overview

The Set-NetConnectionProfile cmdlet modifies existing network connection profiles on the local computer. These profiles store settings for network connections, such as the connection name, network name, security settings, and proxy settings.

Syntax

Set-NetConnectionProfile [-Name] <string> [-NetworkCategory] <string> [-ConnectionType] <string> [-InterfaceIndex] <int> [-IPv4Address] <string[]> [-IPv6Address] <string[]> [-IPv4DefaultGateway] <string[]> [-IPv6DefaultGateway] <string[]> [-DNSServerAddress] <string[]> [-Security] <PSCredential> [-NetworkAuthentication] <string> [-RequireAdminRights] <bool> [-Proxy] <PSCredential> [-ProxyEnable] <bool> [-ProxyAddress] <string> [-ProxyBypassList] <string[]> [-ProtectionLevel] <string> [-AcceptAutomatically] <bool> [-Unrestricted] <bool> [-Confirm] <bool> [-WhatIf] <bool>

Options/Flags

  • Name: Specifies the name of the network connection profile to modify.
  • NetworkCategory: Specifies the network category for the connection profile. Valid values are “Private”, “DomainAuthenticated”, “Public”, and “Unknown”.
  • ConnectionType: Specifies the type of network connection for the connection profile. Valid values are “Ethernet”, “Wireless”, “DialUp”, and “Other”.
  • InterfaceIndex: Specifies the interface index for the connection profile.
  • IPv4Address: Specifies an array of IPv4 addresses to configure for the connection profile.
  • IPv6Address: Specifies an array of IPv6 addresses to configure for the connection profile.
  • IPv4DefaultGateway: Specifies an array of IPv4 default gateways to configure for the connection profile.
  • IPv6DefaultGateway: Specifies an array of IPv6 default gateways to configure for the connection profile.
  • DNSServerAddress: Specifies an array of DNS server addresses to configure for the connection profile.
  • Security: Specifies the credentials to use for secure network authentication.
  • NetworkAuthentication: Specifies the network authentication method to use for the connection profile. Valid values are “None”, “Managed”, and “UnManaged”.
  • RequireAdminRights: Specifies whether to require administrator rights to connect to the network.
  • Proxy: Specifies the credentials to use for proxy authentication.
  • ProxyEnable: Specifies whether to enable the proxy server for the connection profile.
  • ProxyAddress: Specifies the proxy server address to use for the connection profile.
  • ProxyBypassList: Specifies an array of URLs to bypass the proxy server for.
  • ProtectionLevel: Specifies the protection level to use for the connection profile. Valid values are “None”, “AcceptUnsigned”, “Demand”, and “Mandatory”.
  • AcceptAutomatically: Specifies whether to accept network connections automatically.
  • Unrestricted: Specifies whether to allow unrestricted access to the network.
  • Confirm: Prompts for confirmation before executing the command.
  • WhatIf: Shows what would happen if the command is executed but does not actually execute it

Examples

Example 1: Modify a connection profile with a specified name

Set-NetConnectionProfile -Name "MyVPN" -IPv4Address "192.168.1.10" -IPv4DefaultGateway "192.168.1.1" -DNSServerAddress "8.8.8.8", "8.8.4.4"

Example 2: Disable proxy settings for a connection profile

Set-NetConnectionProfile -Name "MyConnection" -ProxyEnable $false

Common Issues

Issue: Setting network connection profile fails with an error message indicating that the profile already exists.

Solution: Verify that the specified profile name does not already exist. If it does, use a different name or delete the existing profile before creating a new one.

Integration

The Set-NetConnectionProfile cmdlet can be used with other PowerShell cmdlets, such as Get-NetConnectionProfile and New-NetConnectionProfile, to manage network connection profiles on the local computer.