Skip to content

[Bug]: Revert Script for Network Connectivity Check isn't working anymore #614

@3c7b1b91-0c9d-40a8-88bf-6e3c7f28b3e5

Description

Description

Trying to run all Disable Connectivity Checks on Revert mode gives me this error and the icon is broken, as a consequence I can't login on MS Teams anymore.

--- Disable active connectivity tests (breaks internet connection status, captive portals) (revert)
The operation completed successfully.
The operation completed successfully. Note: For the changes to fully take effect, please restart your computer. --- Disable passive connectivity tests (breaks internet connection status) (revert) The operation completed successfully. The operation completed successfully.
--- Remove "Network Connectivity Status Indicator (NCSI)" app (breaks internet connection status icon) (revert)
Removing registry key at "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\S-1-5-21-4218298140-1662697426-2370780766-1002\NcsiUwpApp_8wekyb3d8bbwe".
Skipping, no action needed, registry key "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\S-1-5-21-4218298140-1662697426-2370780766-1002\NcsiUwpApp_8wekyb3d8bbwe" does not exist.
Starting the installation process for "NcsiUwpApp"...
Checking if "NcsiUwpApp" is installed on another user profile...
Found package "NcsiUwpApp_1000.25128.1000.0_neutral_neutral_8wekyb3d8bbwe".
Manifest file not found for "NcsiUwpApp" on another user profile: "C:\Windows\SystemApps\NcsiUwpApp_8wekyb3d8bbwe\AppxManifest.xml".
Trying to install "NcsiUwpApp" using its package family name: "NcsiUwpApp_8wekyb3d8bbwe" from system installation...
WARNING: Error installing using package family name: Deployment failed with HRESULT: 0x80073CF0, Package could not be
opened.

error 0x80070002: Opening file from location: AppxManifest.xml failed with error: The system cannot find the file
specified.
.

NOTE: For additional information, look for [ActivityId] 456b2e87-67e8-0006-b7dd-6b45e867dc01 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 456b2e87-67e8-0006-b7dd-6b45e867dc01
Unable to reinstall the requested package (NcsiUwpApp). It appears to no longer be included in this version of
Windows. You may search for it or an alternative in the Microsoft Store or consider using an earlier version of
Windows where this package was originally provided.
At line:1 char:2112

  • ... ssage)"; }; throw "Unable to reinstall the requested package ($packag ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Unable to reins...nally provided.:String) [], RuntimeException
    • FullyQualifiedErrorId : Unable to reinstall the requested package (NcsiUwpApp). It appears to no longer be inclu
      ded in this version of Windows. You may search for it or an alternative in the Microsoft Store or consider using a
      n earlier version of Windows where this package was originally provided.

Removing registry key at "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\NcsiUwpApp_8wekyb3d8bbwe".
Skipping, no action needed, registry key "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\NcsiUwpApp_8wekyb3d8bbwe" does not exist.
--- Block Microsoft connectivity check hosts (breaks internet connection status, captive portals) (revert)
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
Processing removal for IPv4 entry.
Successfully removed the entry.
Processing removal for IPv6 entry.
Successfully removed the entry.
--- Disable "Network Location Awareness (NLA)" service (breaks auto-reconnect, connectivity status, network identification) (revert)
Skipping: Windows (10.0.26200) is above maximum 10.0.19045 (Windows10-MostRecent)
--- Disable "Network List Service (NLS)" service (breaks connectivity status, network identification, network connection icon, connectivity with some Microsoft apps) (revert)
Skipping: Windows (10.0.26200) is above maximum 10.0.19045 (Windows10-MostRecent)

It seems there was an error there.

How can I revert it?

How can the bug be recreated?

Trying to run all Disable Connectivity Checks on Revert mode gives me this error and the icon is broken, as a consequence I can't login on MS Teams anymore.

Operating system

Windows 11 Pro / 25H2 / 26200.7171 / Windows Feature Experience Pack 1000.26100.265.0

Script file

@echo off
:: https://privacy.sexy — v0.13.8 — Mon, 08 Dec 2025 02:14:53 GMT
:: Ensure PowerShell is available
where PowerShell >nul 2>&1 || (
echo PowerShell is not available. Please install or enable PowerShell.
pause & exit 1
)
:: Ensure admin privileges
fltmc >nul 2>&1 || (
echo Administrator privileges are required.
PowerShell Start -Verb RunAs '%0' 2> nul || (
echo Right-click on the script and select "Run as administrator".
pause & exit 1
)
exit 0
)
:: Initialize environment
setlocal EnableExtensions DisableDelayedExpansion

:: Disable active connectivity tests (breaks internet connection status, captive portals) (revert)
echo --- Disable active connectivity tests (breaks internet connection status, captive portals) (revert)
:: Delete the registry value "HKLM\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator!NoActiveProbe"
PowerShell -ExecutionPolicy Unrestricted -Command "reg delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator' /v 'NoActiveProbe' /f 2>$null"
:: Set the registry value "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet!EnableActiveProbing"
PowerShell -ExecutionPolicy Unrestricted -Command "$revertData = '1'; reg add 'HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet' /v 'EnableActiveProbing' /t 'REG_DWORD' /d "^""$revertData"^"" /f"
:: Suggest restarting computer for changes to take effect
PowerShell -ExecutionPolicy Unrestricted -Command "$message = 'For the changes to fully take effect, please restart your computer.'; $warn = $false; if ($warn) { Write-Warning "^""$message"^""; } else { Write-Host "^""Note: "^"" -ForegroundColor Blue -NoNewLine; Write-Output "^""$message"^""; }"
:: ----------------------------------------------------------

:: Disable passive connectivity tests (breaks internet connection status) (revert)
echo --- Disable passive connectivity tests (breaks internet connection status) (revert)
:: Delete the registry value "HKLM\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator!DisablePassivePolling"
PowerShell -ExecutionPolicy Unrestricted -Command "reg delete 'HKLM\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator' /v 'DisablePassivePolling' /f 2>$null"
:: Delete the registry value "HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet!PassivePollPeriod"
PowerShell -ExecutionPolicy Unrestricted -Command "reg delete 'HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet' /v 'PassivePollPeriod' /f 2>$null"
:: ----------------------------------------------------------

:: Remove "Network Connectivity Status Indicator (NCSI)" app (breaks internet connection status icon) (revert)
echo --- Remove "Network Connectivity Status Indicator (NCSI)" app (breaks internet connection status icon) (revert)
:: Remove ability to remove system app 'NcsiUwpApp' to match operating system defaults
:: Restore "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife$CURRENT_USER_SID\NcsiUwpApp_8wekyb3d8bbwe" registry key by deleting it
PowerShell -ExecutionPolicy Unrestricted -Command "$keyPath='HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife$CURRENT_USER_SID\NcsiUwpApp_8wekyb3d8bbwe'; $registryHive = $keyPath.Split('')[0]; $registryPath = "^""$($registryHive):$($keyPath.Substring($registryHive.Length))"^""; $userSid = (New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([Security.Principal.SecurityIdentifier]).Value; $registryPath = $registryPath.Replace('$CURRENT_USER_SID', $userSid); Write-Host "^""Removing registry key at "^""$registryPath"^""."^""; if (-not (Test-Path -LiteralPath $registryPath)) { Write-Host "^""Skipping, no action needed, registry key "^""$registryPath"^"" does not exist."^""; exit 0; }; try { Remove-Item -LiteralPath $registryPath -Force -ErrorAction Stop | Out-Null; Write-Host "^""Successfully removed the registry key at path "^""$registryPath"^""."^""; } catch { Write-Error "^""Failed to remove the registry key at path "^""$registryPath"^"": $($.Exception.Message)"^""; }"
:: Reinstall 'NcsiUwpApp' if it was previously uninstalled
PowerShell -ExecutionPolicy Unrestricted -Command "$packageName='NcsiUwpApp'; $publisherId='8wekyb3d8bbwe'; if (Get-AppxPackage -Name $packageName) { Write-Host "^""Skipping, "^""$packageName"^"" is already installed for the current user."^""; exit 0; }; Write-Host "^""Starting the installation process for "^""$packageName"^""..."^""; <# Attempt installation using the manifest file #>; Write-Host "^""Checking if "^""$packageName"^"" is installed on another user profile..."^""; $packages = @(Get-AppxPackage -AllUsers $packageName); if (!$packages) { Write-Host "^"""^""$packageName"^"" is not installed on any other user profiles."^""; } else { foreach ($package in $packages) { Write-Host "^""Found package "^""$($package.PackageFullName)"^""."^""; $installationDir = $package.InstallLocation; if ([string]::IsNullOrWhiteSpace($installationDir)) { Write-Warning "^""Installation directory for "^""$packageName"^"" is not found or invalid."^""; continue; }; $manifestPath = Join-Path -Path $installationDir -ChildPath 'AppxManifest.xml'; try { if (-Not (Test-Path "^""$manifestPath"^"")) { Write-Host "^""Manifest file not found for "^""$packageName"^"" on another user profile: "^""$manifestPath"^""."^""; continue; }; } catch { Write-Warning "^""An error occurred while checking for the manifest file: $($
.Exception.Message)"^""; continue; }; Write-Host "^""Manifest file located. Trying to install using the manifest: "^""$manifestPath"^""..."^""; try { Add-AppxPackage -DisableDevelopmentMode -Register "^""$manifestPath"^"" -ErrorAction Stop; Write-Host "^""Successfully installed "^""$packageName"^"" using its manifest file."^""; exit 0; } catch { Write-Warning "^""Error installing from manifest: $($.Exception.Message)"^""; }; }; }; <# Attempt installation using the package family name #>; $packageFamilyName = "^""$($packageName)$($publisherId)"^""; Write-Host "^""Trying to install "^""$packageName"^"" using its package family name: "^""$packageFamilyName"^"" from system installation..."^""; try { Add-AppxPackage -RegisterByFamilyName -MainPackage $packageFamilyName -ErrorAction Stop; Write-Host "^""Successfully installed "^""$packageName"^"" using its package family name."^""; exit 0; } catch { Write-Warning "^""Error installing using package family name: $($.Exception.Message)"^""; }; throw "^""Unable to reinstall the requested package ($packageName). "^"" + "^""It appears to no longer be included in this version of Windows. "^"" + "^""You may search for it or an alternative in the Microsoft Store or "^"" + "^""consider using an earlier version of Windows where this package was originally provided."^"""
:: Remove 'NcsiUwpApp' from deprovisioned list to allow reinstall during updates.
:: Restore "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\NcsiUwpApp_8wekyb3d8bbwe" registry key by deleting it
PowerShell -ExecutionPolicy Unrestricted -Command "$keyPath='HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\NcsiUwpApp_8wekyb3d8bbwe'; $registryHive = $keyPath.Split('')[0]; $registryPath = "^""$($registryHive):$($keyPath.Substring($registryHive.Length))"^""; Write-Host "^""Removing registry key at "^""$registryPath"^""."^""; if (-not (Test-Path -LiteralPath $registryPath)) { Write-Host "^""Skipping, no action needed, registry key "^""$registryPath"^"" does not exist."^""; exit 0; }; try { Remove-Item -LiteralPath $registryPath -Force -ErrorAction Stop | Out-Null; Write-Host "^""Successfully removed the registry key at path "^""$registryPath"^""."^""; } catch { Write-Error "^""Failed to remove the registry key at path "^""$registryPath"^"": $($
.Exception.Message)"^""; }"
:: ----------------------------------------------------------

:: Block Microsoft connectivity check hosts (breaks internet connection status, captive portals) (revert)
echo --- Block Microsoft connectivity check hosts (breaks internet connection status, captive portals) (revert)
:: Remove hosts entries for msftncsi.com
PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='msftncsi.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $_"^""; continue; }; }" :: Remove hosts entries for dns.msftncsi.com PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='dns.msftncsi.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $_"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $_"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $"^""; continue; }; }"
:: Remove hosts entries for ipv6.msftncsi.com
PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='ipv6.msftncsi.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $
"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $_"^""; continue; }; }" :: Remove hosts entries for msftconnecttest.com PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='msftconnecttest.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $_"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $_"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $"^""; continue; }; }"
:: Remove hosts entries for www.msftconnecttest.com
PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='www.msftconnecttest.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $_"^""; continue; }; }" :: Remove hosts entries for ipv6.msftconnecttest.com PowerShell -ExecutionPolicy Unrestricted -Command "$domain ='ipv6.msftconnecttest.com'; $hostsFilePath = "^""$env:SYSTEMROOT\System32\drivers\etc\hosts"^""; $comment = "^""managed by privacy.sexy"^""; $hostsFileEncoding = [System.Text.Encoding]::UTF8; $blockingHostsEntries = @(; @{ AddressType = "^""IPv4"^""; IPAddress = '0.0.0.0'; }; @{ AddressType = "^""IPv6"^""; IPAddress = '::1'; }; ); try { $isHostsFilePresent = Test-Path -Path $hostsFilePath -PathType Leaf -ErrorAction Stop; } catch { Write-Error "^""Failed to check hosts file existence. Error: $_"^""; exit 1; }; if (-Not $isHostsFilePresent) { Write-Output 'Skipping, the hosts file does not exist.'; exit 0; }; foreach ($blockingEntry in $blockingHostsEntries) { Write-Output "^""Processing removal for $($blockingEntry.AddressType) entry."^""; try { $hostsFileContents = [System.IO.File]::ReadAllText($hostsFilePath, $hostsFileEncoding); } catch { Write-Error "^""Failed to read the hosts file for removal. Error: $_"^""; continue; }; $hostsEntryLine = "^""$($blockingEntry.IPAddress)t$domain $([char]35) $comment"^""; if ([String]::IsNullOrWhiteSpace($hostsFileContents) -Or (-Not $hostsFileContents.Contains($hostsEntryLine))) { Write-Output 'Skipping, entry not found.'; continue; }; $hostsEntryRemovalPattern = [regex]::Escape($hostsEntryLine) + "^""(\r?\n)?"^""; $hostsFileContentAfterRemoval = $hostsFileContents -Replace $hostsEntryRemovalPattern, "^"""^""; try { [System.IO.File]::WriteAllText($hostsFilePath, $hostsFileContentAfterRemoval, $hostsFileEncoding); Write-Output 'Successfully removed the entry.'; } catch { Write-Error "^""Failed to remove the entry. Error: $_"^""; continue; }; }"
:: ----------------------------------------------------------

:: Disable "Network Location Awareness (NLA)" service (breaks auto-reconnect, connectivity status, network identification) (revert)
echo --- Disable "Network Location Awareness (NLA)" service (breaks auto-reconnect, connectivity status, network identification) (revert)
:: Restore service(s) to default state: NlaSvc
:: This operation will not run on Windows versions later than Windows10-MostRecent.
PowerShell -ExecutionPolicy Unrestricted -Command "$versionName = 'Windows10-MostRecent'; $buildNumber = switch ($versionName) { 'Windows11-21H2' { '10.0.22000' }; 'Windows10-MostRecent' { '10.0.19045' }; 'Windows10-22H2' { '10.0.19045' }; 'Windows10-1909' { '10.0.18363' }; 'Windows10-1903' { '10.0.18362' }; default { throw "^""Internal privacy$([char]0x002E)sexy error: No build for maximum Windows '$versionName'"^""; }; }; $maxVersion=[System.Version]::Parse($buildNumber); $ver = [Environment]::OSVersion.Version; $verNoPatch = [System.Version]::new($ver.Major, $ver.Minor, $ver.Build); if ($verNoPatch -gt $maxVersion) { Write-Output "^""Skipping: Windows ($verNoPatch) is above maximum $maxVersion ($versionName)"^""; Exit 0; }; $serviceName = 'NlaSvc'; $defaultStartupMode = 'Automatic'; $ignoreMissingOnRevert = $false; Write-Host "^""Reverting service "^""$serviceName"^"" start to "^""$defaultStartupMode"^""."^""; <# -- 1. Skip if service does not exist #>; $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue; if (!$service) { if ($ignoreMissingOnRevert) { Write-Output "^""Skipping: The service "^""$serviceName"^"" is not found. No action required."^""; Exit 0; }; Write-Warning "^""Failed to revert changes to the service "^""$serviceName"^"". The service is not found."^""; Exit 1; }; <# -- 2. Enable or skip if already enabled #>; $startupType = $service.StartType <# Does not work before .NET 4.6.1 #>; if (!$startupType) { $startupType = (Get-WmiObject -Query "^""Select StartMode From Win32_Service Where Name='$serviceName'"^"" -ErrorAction Ignore).StartMode; if (!$startupType) { $startupType = (Get-WmiObject -Class Win32_Service -Property StartMode -Filter "^""Name='$serviceName'"^"" -ErrorAction Ignore).StartMode; }; }; if ($startupType -eq "^""$defaultStartupMode"^"") { Write-Host "^"""^""$serviceName"^"" has already expected startup mode: "^""$defaultStartupMode"^"". No action required."^""; } else { try { Set-Service -Name "^""$serviceName"^"" -StartupType "^""$defaultStartupMode"^"" -Confirm:$false -ErrorAction Stop; Write-Host "^""Reverted "^""$serviceName"^"" with "^""$defaultStartupMode"^"" start, this may require restarting your computer."^""; } catch { Write-Error "^""Failed to enable "^""$serviceName"^"": $"^""; Exit 1; }; }; <# -- 4. Start if not running (must be enabled first) #>; if ($defaultStartupMode -eq 'Automatic' -or $defaultStartupMode -eq 'Boot' -or $defaultStartupMode -eq 'System') { if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Running) { Write-Host "^"""^""$serviceName"^"" is not running, starting it."^""; try { Start-Service $serviceName -ErrorAction Stop; Write-Host "^""Started "^""$serviceName"^"" successfully."^""; } catch { Write-Warning "^""Failed to start "^""$serviceName"^"", requires restart, it will be started after reboot.rn$"^""; }; } else { Write-Host "^"""^""$serviceName"^"" is already running, no need to start."^""; }; }"
:: ----------------------------------------------------------

:: Disable "Network List Service (NLS)" service (breaks connectivity status, network identification, network connection icon, connectivity with some Microsoft apps) (revert)
echo --- Disable "Network List Service (NLS)" service (breaks connectivity status, network identification, network connection icon, connectivity with some Microsoft apps) (revert)
:: Restore service(s) to default state: netprofm
:: This operation will not run on Windows versions later than Windows10-MostRecent.
PowerShell -ExecutionPolicy Unrestricted -Command "$versionName = 'Windows10-MostRecent'; $buildNumber = switch ($versionName) { 'Windows11-21H2' { '10.0.22000' }; 'Windows10-MostRecent' { '10.0.19045' }; 'Windows10-22H2' { '10.0.19045' }; 'Windows10-1909' { '10.0.18363' }; 'Windows10-1903' { '10.0.18362' }; default { throw "^""Internal privacy$([char]0x002E)sexy error: No build for maximum Windows '$versionName'"^""; }; }; $maxVersion=[System.Version]::Parse($buildNumber); $ver = [Environment]::OSVersion.Version; $verNoPatch = [System.Version]::new($ver.Major, $ver.Minor, $ver.Build); if ($verNoPatch -gt $maxVersion) { Write-Output "^""Skipping: Windows ($verNoPatch) is above maximum $maxVersion ($versionName)"^""; Exit 0; }; $serviceName = 'netprofm'; $defaultStartupMode = 'Manual'; $ignoreMissingOnRevert = $false; Write-Host "^""Reverting service "^""$serviceName"^"" start to "^""$defaultStartupMode"^""."^""; <# -- 1. Skip if service does not exist #>; $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue; if (!$service) { if ($ignoreMissingOnRevert) { Write-Output "^""Skipping: The service "^""$serviceName"^"" is not found. No action required."^""; Exit 0; }; Write-Warning "^""Failed to revert changes to the service "^""$serviceName"^"". The service is not found."^""; Exit 1; }; <# -- 2. Enable or skip if already enabled #>; $startupType = $service.StartType <# Does not work before .NET 4.6.1 #>; if (!$startupType) { $startupType = (Get-WmiObject -Query "^""Select StartMode From Win32_Service Where Name='$serviceName'"^"" -ErrorAction Ignore).StartMode; if (!$startupType) { $startupType = (Get-WmiObject -Class Win32_Service -Property StartMode -Filter "^""Name='$serviceName'"^"" -ErrorAction Ignore).StartMode; }; }; if ($startupType -eq "^""$defaultStartupMode"^"") { Write-Host "^"""^""$serviceName"^"" has already expected startup mode: "^""$defaultStartupMode"^"". No action required."^""; } else { try { Set-Service -Name "^""$serviceName"^"" -StartupType "^""$defaultStartupMode"^"" -Confirm:$false -ErrorAction Stop; Write-Host "^""Reverted "^""$serviceName"^"" with "^""$defaultStartupMode"^"" start, this may require restarting your computer."^""; } catch { Write-Error "^""Failed to enable "^""$serviceName"^"": $"^""; Exit 1; }; }; <# -- 4. Start if not running (must be enabled first) #>; if ($defaultStartupMode -eq 'Automatic' -or $defaultStartupMode -eq 'Boot' -or $defaultStartupMode -eq 'System') { if ($service.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Running) { Write-Host "^"""^""$serviceName"^"" is not running, starting it."^""; try { Start-Service $serviceName -ErrorAction Stop; Write-Host "^""Started "^""$serviceName"^"" successfully."^""; } catch { Write-Warning "^""Failed to start "^""$serviceName"^"", requires restart, it will be started after reboot.rn$"^""; }; } else { Write-Host "^"""^""$serviceName"^"" is already running, no need to start."^""; }; }"
:: ----------------------------------------------------------

:: Pause the script to view the final state
pause
:: Restore previous environment settings
endlocal
:: Exit the script successfully
exit /b 0

Screenshots

Image

Additional information

Please share a script to restore it to be able to login on MS Teams.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions