Enable and Disable RDP NLA using PowerShell

Enable_RDP_NLA

#Powershell script to enable Network Level Authentication for Remote Desktop Services Connections
#The need arose when trying to RDP using a third party application and it gave the following error:
#The remote computer '<machine name>' requires Network Level Authentication, which your computer does not support.

#The following script has to be run on the remote machine using RDC (Remote Desktop Connection) on which you are attempting to RDP to and gives the error.
# Post that you should be able to successfully run RDP using the third party application.

# Comparative .reg script is as below:
# Windows Registry Editor Version 5.00

# [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]
# "UserAuthentication"=dword:00000000
# "SecurityLayer"=dword:00000000

# Author - Vikram Bedi 
# [email protected] 

#Powershell v2.0
#v1.0 Initial Script

$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"

$Name1 = "UserAuthentication"
$value1 = "00000001"
IF(!(Test-Path $registryPath))
  {
    New-Item -Path $registryPath -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null
  }
 ELSE 
  {
    New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null
  }
$Name2 = "SecurityLayer"
$value2 = "00000001"
IF(!(Test-Path $registryPath))
  {
    New-Item -Path $registryPath -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null
  }
 ELSE 
  {
    New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null
  }

Disable_RDP_NLA

#Powershell script to enable Network Level Authentication for Remote Desktop Services Connections
#The need arose when trying to RDP using a third party application and it gave the following error:
#The remote computer '<machine name>' requires Network Level Authentication, which your computer does not support.

# The following script has to be run on the remote machine using RDC (Remote Desktop Connection) on which you are attempting to RDP to and gives the error.
# Post that you should be able to successfully run RDP using the third party application.

# Comparative .reg script is as below:
# Windows Registry Editor Version 5.00

# [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]
# "UserAuthentication"=dword:00000000
# "SecurityLayer"=dword:00000000

# Author - Vikram Bedi 
# [email protected] 

#Powershell v2.0
#v1.0 Initial Script

$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"

$Name1 = "UserAuthentication"
$value1 = "00000000"
IF(!(Test-Path $registryPath))
  {
    New-Item -Path $registryPath -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null
  }
 ELSE 
  {
    New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -PropertyType DWORD -Force | Out-Null
  }
$Name2 = "SecurityLayer"
$value2 = "00000000"
IF(!(Test-Path $registryPath))
  {
    New-Item -Path $registryPath -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null
  }
 ELSE 
  {
    New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -PropertyType DWORD -Force | Out-Null
  }

猜你喜欢

转载自blog.51cto.com/549687/2124695
RDP