码迷,mamicode.com
首页 > 系统相关 > 详细

Enable and Disable RDP NLA using PowerShell

时间:2018-06-04 18:24:47      阅读:522      评论:0      收藏:0      [点我收藏+]

标签:RDP

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
  }

Enable and Disable RDP NLA using PowerShell

标签:RDP

原文地址:http://blog.51cto.com/549687/2124695

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!