powershell - Powershell 禁止证书通知
问题描述
我正在编写一个脚本以使用 RDP-Protocoll 从 Windows 10 客户端连接到终端服务器。
背后的想法是:在这些 ThinClient 上,我们有大约 20 个 RDP 文件。大约有 10 个密码需要保护。
因此,如果您总是必须在每个新的 ThinClient 上保存密码,工作量就很大。
但我认为我可以使用 powershell 脚本解决这个问题。我只需要成功打开连接 1 次并保存凭据,然后再保存凭据。
我将首先显示我的代码:
$Server = "xx.yy.zz.xx"
$User = "DOMAIN\User"
$password = "password"
cmdkey /generic:"$Server" /user:"$User" /pass:"$password"
mstsc /v:"$Server"
到目前为止,这有效。
但我总是收到此通知:
这是来自互联网的符号图片,因为我的通知是德文的。完全一样,只是更容易理解。
即使我安装了证书,通知也会不断弹出。
如何使用 Powershell 检查该字段,其中显示Don't ask me again for connection to this computer?
解决方案
好的,我找到了解决方案!当您勾选“不要再问我...”时,会生成一个注册表项
现在我刚刚使用我的 Powershell 脚本添加了必要的注册表项..
function Test-RegistryValue {
param (
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Path,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Value
)
try{
Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
return $true
}
catch{
return $false
}
}
#Certificate warning turn off
$exists = Test-RegistryValue -Path 'HKCU:\Software\Microsoft\Terminal Server Client' -Value 'AuthenticationLevelOverride'
if($exists -eq $False){
reg add "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client" /v "AuthenticationLevelOverride" /t "REG_DWORD" /d 0 /f
}
像这样它在没有这个证书通知的情况下工作!
推荐阅读
- node.js - 如何在Nodejs回调函数之外提取变量的值
- crystal-reports - 水晶报表语言中的列表比较行为
- .net - SQL 函数的表类型输入的 Null、Empty 或默认值
- html - 字体样式:斜体更改 Chrome 上的输入大小?
- python - Pandas 相当于 sql 的月份日期时间
- javascript - 如何检查函数是否执行任何操作?
- javascript - enableWhiteboard() 函数在 Circuit SDK 中收到带有 SERVICE_EXCEPTION 错误的响应
- assembly - X86:寻址方式——寄存器值变化
- enums - 如何传递枚举变量以匹配作为函数参数?
- javascript - 无法使用带有 babel loader 的 web-pack 编译 JSX