【问题标题】:Powershell Suppress Certificate NotificationPowershell 禁止证书通知
【发布时间】:2019-01-13 18:30:55
【问题描述】:

我正在编写一个脚本以使用 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 检查该字段,其中显示 不要再询问我是否连接到这台计算机

【问题讨论】:

  • 尝试使用 netbios 名称 laptop-7 而不是 $Server 名称的 FQDN(意思是:无点),或者将服务器域添加到受信任方。

标签: powershell rdp


【解决方案1】:

好的,我找到了解决方案! 勾选“Dont ask me again...”时会生成一个registry-Key

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

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

【讨论】:

    猜你喜欢
    • 2021-08-25
    • 2021-12-08
    • 1970-01-01
    • 2022-07-03
    • 1970-01-01
    • 2015-01-10
    • 1970-01-01
    • 1970-01-01
    • 2017-09-05
    相关资源
    最近更新 更多