How to fix “An internal error has occurred” during Remote Desktop in Windows 10

If you use Remote Desktop to work with remote computers in Windows environment, you will frequently come across the following error.

An internal error has occurredThis error commonly occurs in Windows 8.1 and 10 when the username for remote computer is saved in Windows registry.

The following video will delete the saved username from Windows registry and the error will go away.

If you work with a lot of remote computers and you probably encounter this error quite often. This will make it cumbersome to browse Windows registry and delete the registry value for every single remote computer. In the next section, I will show you how to create a PowerShell module which will feel and behave like a traditional PowerShell cmdlet. Using this module, you can fix “An internal error has occurred” issue with just a single command.

Creating Fix-RDPError PowerShell Module

Launch the Windows PowerShell console with administrator privilege , paste the following code and hit enter:

$module = New-Item -Path "$env:userprofile\documents\WindowsPowerShell\Modules\Fix-RDPError" -Name Fix-RDPError.psm1 -ItemType File -Force
if($module){
notepad $module
}

This command will create new new PowerShell module file under “$env:userprofile\documents\WindowsPowerShell\Modules” and then opens the modules file in notepad.

Now copy the following code, paste it in notepad and press Ctrl+S to save it.

<#
.Synopsis
Fixes "An internal error has occurred" issue.
.DESCRIPTION
This cmdlet will fix "An internal error has occurred" issue while trying to connect a computer through Remote Desktop.
.Parameter <ComputerName>
This is a required parameter where you need to specify a computer name or IP address of the remote computer.
.EXAMPLE
Fix-RDPError -ComputerName DC01
This command will delete the saved "UsernameHint" value in registry for remote computer DC01, which will fix "An internal error has occurred" issue.
.EXAMPLE
Fix-RDPError -IP 192.168.10.10 -Verbose
This command will verbosely delete the saved "UsernameHint" value in registry for remote computer 192.168.10.10, which will fix "An internal error has occurred" issue.
#>
function Fix-RDPError
{
[CmdletBinding()]
Param
(
# Required parameter ComputerName
[Parameter(Mandatory=$true,
Position=0)]
[Alias ('HostName','cn','Host','Computer', 'IP')]
[string]$ComputerName
)
$BasePath = "HKCU:\SOFTWARE\Microsoft\Terminal Server Client\Servers"
$RegPath = "$BasePath\$ComputerName"
$exists = Test-Path "$BasePath\$ComputerName"
if ($exists) {
if((Get-ItemProperty $RegPath).PSObject.Properties.Name -contains "UsernameHint") {
Write-Host "Saved Username found in registry!" -ForegroundColor Green
Write-Verbose ("Removing the `"UsernameHint`" value from [$RegPath] registry key!")
Remove-ItemProperty -Path $RegPath -Name "UsernameHint" -Force
if($?){
Write-Host "Operation completed successfully!"-ForegroundColor Green
} else {Write-Host "Something went wrong! Try running the command again." -ForegroundColor Red}
}
else {Write-Error "Username is not saved for `"$ComputerName`""}
}
else {Write-Error "Computer name `"$ComputerName`" doesn't exist in registry!"}
}

If you followed the steps correctly, your Fix-RDPError module is now created and ready for use. This module requires you to have administrative privilege on local computer since it involves deleting value(s) from Windows registry.

Using the Fix-RDPError Module

Now that you created the FIx-RDPError module, let me tell you how to use it. Launch a PowerShell console with administrator privilege. copy the following command:

Fix-RDPError -ComputerName SRV01

Make sure you change the SRV01 with your remote computer name.

Fix-RDPError

The module will search for a saved username in Windows registry and deletes it if found. This will fix “An internal error has occurred” issue.

This PowerShell module may be useful for the windows administrators who frequently uses Remote Desktop to connect remote computers and face this error quite often.



Microsoft Certified | Cisco Certified

Leave a Reply