Thursday, November 15, 2018

Set ON/OFF Metered Ethernet Connection on windows 10

For old Windows 10 version you can change ethernet metered connection using registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost
(example at https://4sysops.com/archives/set-windows-10-ethernet-connection-to-metered-with-powershell/ )

But since each Ethernet Metered Connection have it own information (since Windows 10 version 1709 I believe, in Settings / Network & Internet / Ethernet / then select your connection), there is a NEW key to know

Where is Network Card connection metered information:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DusmSvc\Profiles\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\* in REG_DWORD name UserCost indicate if metered or not
with {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} your Network Card GUID
and
UserCost = 0 when Metered is off
UserCost = 2 when Metered is on


Below when metered is On






























You need to restart "Data Usage" Service DusmSvc before your settings take effect



























In registry Network Card ID {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}is in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\Y\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}

With Y= a number



In Powershell to have GUID Network Card
Get-NetAdapter | select InterfaceDescription, InterfaceGuid
or in old Powershell version
Get-WmiObject  Win32_NetworkAdapterConfiguration -filter 'IPEnabled=True' | %{$_.GetRelated('Win32_NetworkAdapter')}| select Description,GUID




















Using this Script SetMeteredEthernetConnection.ps1 you can do it by yourself

PS C:\temp>
.\SetMeteredEthernetConnection.ps1 -MeteredAction DisplayNetworkCardOnly
Display Network Card: 'Intel(R) 82579LM Gigabit Network Connection' ID:'{2FD6004A-2CB4-4B1E-ACEB-CC5792236B44}'
PS C:\temp> .\SetMeteredEthernetConnection.ps1 -MeteredAction DisplayNetworkCardOnly -NetWorkCardLike giga
Display Network Card: 'Intel(R) 82579LM Gigabit Network Connection' ID:'{2FD6004A-2CB4-4B1E-ACEB-CC5792236B44}'
PS C:\temp> .\SetMeteredEthernetConnection.ps1 -MeteredAction DisplayNetworkCardOnly -NetWorkCardLike NOOO
PS C:\temp> .\SetMeteredEthernetConnection.ps1 -MeteredAction MeteredOff
Set MeteredOff to connection Intel(R) 82579LM Gigabit Network Connection
PS C:\temp>




#
# SetMeteredEthernetConnection.ps1
#
# by RICHARD Franck
# 2018-11
#
Param(           
     [parameter(Mandatory=$true,Position=0)][ValidateSet("DisplayNetworkCardOnly","MeteredOn","MeteredOff")][string]$MeteredAction
    ,[string]$NetWorkCardLike=""
)

If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
    Exit
}


if ($MeteredAction -eq "MeteredOn") { $MeteredChoice = 2 } else { $MeteredChoice = 0 }
if ($NetWorkCardLike -eq "") {
    $NetCards = Get-NetAdapter | select InterfaceDescription, InterfaceGuid
} else {
    $NetCards = Get-NetAdapter | Where-Object { $_.InterfaceDescription -Like "*$($NetWorkCardLike)*" } | select InterfaceDescription, InterfaceGuid
}
$RegistryName = "UserCost"
Foreach ($card in $NetCards) {
        if ($MeteredAction -eq "DisplayNetworkCardOnly") {
            Write-Host "Display Network Card: '$($card.InterfaceDescription)' ID:'$($card.InterfaceGuid)'"

        } else {
            Write-Host "Set $($MeteredAction) to connection $($card.InterfaceDescription)"
            $registryPath = "HKLM:\SOFTWARE\Microsoft\DusmSvc\Profiles\$($card.InterfaceGuid)\*"
            New-ItemProperty -Path $registryPath -Name $RegistryName -Value $MeteredChoice -PropertyType DWORD -Force | Out-Null
        }
}
# your settings take effect when you restart "date usage"
DusmSvc  
 Restart-Service -Name DusmSvc  -Force





Wednesday, November 14, 2018

SCCM 'Client certificate' value set to 'None' can be a Metered Network Connection set to Off


As you can see 'Client certificate' value is set to 'None'. I verified all port connection to MP and delete previous certificate 19c5cf9* in C:\ProgramDate\Microsoft\Crypto\RSA\MachineKeys but always same problem
























finally, client log "CcmMessaging.log" permit to help to find solution
Request to http://SRAADEVY01CM101.accor.net/ccm_system/request cannot be fulfilled since use of metered network is not allowed.
Post to http://SRAADEVY01CM101.accor.net/ccm_system/request failed with 0x87d00231.
Request to http://SRAADEVY01CM101.accor.net/ccm_system_windowsauth/request cannot be fulfilled since use of metered network is not allowed.
Post to http://SRAADEVY01CM101.accor.net/ccm_system_windowsauth/request failed with 0x87d00231. 
 

 Metered network is a Windows 10 functionnality which permit to limit data in an Internet connection. Cellular data connections are set as metered by default. Wi-Fi and Ethernet network connections can be set to metered but aren't by default

 Verification on computer
 

 That's the problem:Metered connection is ON  (for a desktop workstation what a weird configuration...surely an human mistake)

So change Metered to OFF




 In CertificateMaintenance.Log file
Creating Signing Certificate...
Successfully created certifcate
Creating Encryption Certificate...Successfully created certifcate



 And now all seems OK


























This is the 1st time I see this problem.I suppose this computer has been installed using an offline installation, or SCCM client have been installed after some other configuration. And SCCM registration NOT work and NOT cummunicate if your are on a metered network.