PowerShell command needed to edit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost

Daniel Call 1 Reputation point
2021-07-13T08:13:00.213+00:00

Hi everyone.

I would like to create a script to edit the values contained in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost - Specifically to change the 3G and 4G values from 2 to 1 so Windows treats them as unmetered connections.

I was able to change this key manually on my test machine by editing the permissions of the key to give myself full access to change the values and it works (Windows no longer restricting data or popping up notification when on a cellular connection which is what I want to achieve).

I need to roll this change out to the entire Azure joined estate, all running Win10. My thoughts were to use a script in Endpoint Manager but I can't seem to get a working PS script to change this key. Can you assist please or is there a smarter way to be achieving this?

Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
330 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. shiva patpi 13,251 Reputation points Microsoft Employee
    2021-07-14T21:15:20.313+00:00

    Hello @Daniel Call ,
    Thanks for your query.
    In general if you want to change the registry key using power shell by logging into Azure VM you can use below command: (in Power Shell prompt)

    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost' -Name 3G -Value 2

    If you have multiple Virtual Machines and with out logging into the machine for changing Registry keys remotely please use below steps:

    1) Create a powe rshell script file with name EditReg.ps1 enter the below code in that script file:
    Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost' -Name 3G -Value 2

    2) Now run the below command in the Azure CLI prompt:

    Invoke-AzVMRunCommand -ResourceGroupName "win10" -Name "win10" -CommandId "RunPowerShellScript" -ScriptPath .\EditReg.ps1

    Above is the azure powershell cmdlet which is mainly used to run powershell scripts remotely on an azure VM. (make sure to pass your resource group name and Azure VM Name)

    Example of my testing locally:

    114801-image.png

    After running the above command:

    114802-image.png

    Test it out for one of the Azure VM.

    Kindly let us know if you have additional questions !

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.