首页 > 解决方案 > 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

标签: powershellrdp

解决方案


好的,我找到了解决方案!当您勾选“不要再问我...”时,会生成一个注册表项

现在我刚刚使用我的 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 
}

像这样它在没有这个证书通知的情况下工作!


推荐阅读