远程桌面开启(命名空间)

将某个普通域用户加入到远程桌面组方法:在组策略中-受限制的组:remote desktop users:testj\remoteuser

DC远程用户登录方法:组策略中-本地安全策略--用户权限分配:运行通过远程桌面登录:加入其用户,默认remote desktop users组在DC上没有远程登录权限,只有administrator

==================================================================================

 

打开wmi管理控制台:wmimgmt.msc

gwmi -query "select * from win32_service"
get-wmiobject -query "select * from win32_service where name='WinRM'" -computername server01, server02


root\cimv2\TerminalServices 终端服务相关设置命名空间说明:
\root\CIMV2\TerminalServices on Windows Server 2008
\root\CIMV2 on Windows Server 2003

 

本地计算机执行如下命令即可

$ts=get-WMIObject Win32_TerminalServiceSetting -Namespace ROOT\CIMV2\TerminalServices

 

远程计算机启用远程桌面:
$tss = Get-WMIObject Win32_TerminalServiceSetting -Namespace ROOT\CIMV2\TerminalServices -ComputerName win2012client -Authentication 6

注:远程计算机必须使用 -Authentication 参数,否则会提示“Access Denied”,本地计算机不需要

指定用于 WMI 连接的身份验证级别。有效值包括:

-1:不变

0:默认值

1:无(不执行身份验证。)

2:连接(仅当客户端与应用程序建立了关系时才执行身份验证。)

3:调用(应用程序收到请求时只在每次调用的开始执行身份验证。)

4:数据包(对从客户端收到的所有数据执行身份验证。)

5:数据包整体性(所有在客户端和应用程序之间传送的数据都经过身份验证和验证。)

6:数据包保密性(使用其他身份验证等级的属性,并且所有数据都加密。)

 

$tss.SetAllowTSConnections 查看远程桌面是否已启用
$tss.SetAllowTSConnections(1) 启用远程桌面
$tss.SetAllowTSConnections(0) 关闭远程桌面

$tss.SetSingleSession(0) 开启远程桌面多用户模式
$tss.SetSingleSession(1) 关闭远程桌面多用户模式
通过修改注册表方式开启远程桌面多用户模式,设置为0生效,默认为1,等同于$tss.SetSingleSession()
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fSingleSessionPerUser -Value 0

 

取消选中“仅允许运行使用网络级别身份验证的远程桌面的计算机连接”
$tsgs = Get-WMIObject Win32_Tsgeneralsetting -Namespace ROOT\CIMV2\TerminalServices -ComputerName win2012client -Authentication 6
$tsgs.UserAuthenticationRequired 查看是否已选中“仅允许运行使用网络级别身份验证的远程桌面的计算机连接”
$tsgs.SetUserAuthenticationRequired(0) 未选中
$tsgs.SetUserAuthenticationRequired(1) 选中

 

=================================================================

更改会话断开属性:

$tss=Get-WMIObject Win32_TssessionSetting -Namespace ROOT\CIMV2\TerminalServices
$tss.TimeLimitPolicy=0 #启用“改写用户配置(时间限制)”,值为1则表示不启用
$tss.put() #须先put后再设置TimeLimit
$tss.TimeLimit("IdleSessionLimit",1800000) #设置空闲会话限制为30分钟。ActiveSessionLimit,DisconnectedSessionLimit

#启用“改写用户设置:达到会话限制或连接中断时”
$tss.BrokenConnectionPolicy = 0
$tss.TimeLimitPolicy = 0
$tss.put()
$tss.BrokenConnection(0) # 值为0表示从会话断开,1表示结束会话

posted on 2013-07-05 14:47  momingliu11  阅读(1107)  评论(2编辑  收藏  举报