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 
# vikram.bedi.it@gmail.com 

#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 
# vikram.bedi.it@gmail.com 

#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
  }

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...