Skip to content

ProxySettings

dscbot edited this page Jun 7, 2024 · 7 revisions

ProxySettings

Parameters

Parameter Attribute DataType Description Allowed Values
Target Key String Specifies if the proxy settings should be set for the LocalMachine or for the CurrentUser. Defaults to 'LocalMachine'. LocalMachine, CurrentUser
Ensure Write String Specifies if proxy settings should be set. Defaults to 'Present'. Present, Absent
ConnectionType Write String Defines if the proxy settings should be configured for default connections, legacy connections or all connections. Defaults to 'All'. All, Default, Legacy
EnableAutoDetection Write Boolean Enable automatic detection of the proxy settings. Defaults to 'False'.
EnableAutoConfiguration Write Boolean Use automatic configuration script for specifying proxy settings. Defaults to 'False'.
EnableManualProxy Write Boolean Use manual proxy server settings. Defaults to 'False'.
AutoConfigURL Write String The URL of the automatic configuration script to specify the proxy settings. Should be specified if 'EnableAutoConfiguration' is 'True'.
ProxyServer Write String The address and port of the manual proxy server to use. Should be specified if 'EnableManualProxy' is 'True'.
ProxyServerExceptions Write StringArray[] Bypass proxy server for addresses starting with addresses in this list.
ProxyServerBypassLocal Write Boolean Bypass proxy server for local addresses. Defaults to 'False'.

Description

The resource is used to configure internet proxy settings for a computer (LocalMachine) or a user account (CurrentUser).

Target

The Target parameter is used to specify whether to configure the proxy settings for the machine or for a specific user account.

If the Target is set to CurrentUser then the proxy settings will be configured for the user account that the resource runs under. This is usually the account the DSC Local Configuration Manager runs under, which is LocalSystem.

You can configure the proxy settings on a different user account by specifying the PsDscRunAsCredential in the resource configuration.

See this page for more information.

Examples

Example 1

Sets the computer to automatically detect the proxy settings.

Configuration ProxySettings_AutoDetectProxy_Config
{
    Import-DSCResource -ModuleName NetworkingDsc

    Node localhost
    {
        ProxySettings AutoDetectProxy
        {
            Target                  = 'LocalMachine'
            Ensure                  = 'Present'
            EnableAutoDetection     = $true
            EnableAutoConfiguration = $false
            EnableManualProxy       = $false
        }
    }
}

Example 2

Sets the computer to use an automatic WPAD configuration script that will be downloaded from the URL 'http://wpad.contoso.com/wpad.dat'.

Configuration ProxySettings_AutoConfigurationProxy_Config
{
    Import-DSCResource -ModuleName NetworkingDsc

    Node localhost
    {
        ProxySettings AutoConfigurationProxy
        {
            Target                  = 'LocalMachine'
            Ensure                  = 'Present'
            EnableAutoDetection     = $false
            EnableAutoConfiguration = $true
            EnableManualProxy       = $false
            AutoConfigURL           = 'http://wpad.contoso.com/wpad.dat'
        }
    }
}

Example 3

Sets the computer to use a manually configured proxy server with the address 'proxy.contoso.com' on port 8888. Traffic to addresses starting with 'web1' or 'web2' or any local addresses will not be sent to the proxy.

Configuration ProxySettings_ManualProxy_Config
{
    Import-DSCResource -ModuleName NetworkingDsc

    Node localhost
    {
        ProxySettings ManualProxy
        {
            Target                  = 'LocalMachine'
            Ensure                  = 'Present'
            EnableAutoDetection     = $false
            EnableAutoConfiguration = $false
            EnableManualProxy       = $true
            ProxyServer             = 'proxy.contoso.com:8888'
            ProxyServerExceptions   = 'web1', 'web2'
            ProxyServerBypassLocal  = $true
        }
    }
}

Example 4

Sets a user account to use a manually configured proxy server with the address 'proxy.contoso.com' on port 8888. Traffic to addresses starting with 'web1' or 'web2' or any local addresses will not be sent to the proxy.

The user account that the proxy settings are configured for will be the account that applies the resource.

Configuration ProxySettings_ManualProxyForCurrentUser_Config
{
    Import-DSCResource -ModuleName NetworkingDsc

    Node localhost
    {
        ProxySettings ManualProxy
        {
            Target                  = 'CurrentUser'
            Ensure                  = 'Present'
            EnableAutoDetection     = $false
            EnableAutoConfiguration = $false
            EnableManualProxy       = $true
            ProxyServer             = 'proxy.contoso.com:8888'
            ProxyServerExceptions   = 'web1', 'web2'
            ProxyServerBypassLocal  = $true
        }
    }
}