powershell 自动连接到RDP客户端

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 自动连接到RDP客户端相关的知识,希望对你有一定的参考价值。

##########################################################################################
#
# Name: connect_RDP.ps1
# Author: Tobias Wetner
# Purpose: Connect RDP Sessions
#
#
##########################################################################################
function Connect-RDP {
 
 
  param (
    [Parameter(Mandatory=$true)]
    $ComputerName,
 
    [System.Management.Automation.Credential()]
    $Credential
  )
 
  # take each computername and process it individually
  $ComputerName | ForEach-Object {
 
    # if the user has submitted a credential, store it
    # safely using cmdkey.exe for the given connection
    if ($PSBoundParameters.ContainsKey('Credential'))
    {
      # extract username and password from credential
      $User = $Credential.UserName
      $Password = $Credential.GetNetworkCredential().Password
 
      # save information using cmdkey.exe
      cmdkey.exe /generic:$_ /user:$User /pass:$Password
    }
 
    # initiate the RDP connection
    # connection will automatically use cached credentials
    # if there are no cached credentials, you will have to log on
    # manually, so on first use, make sure you use -Credential to submit
    # logon credential
 
    mstsc.exe /v $_ /f
  }
}

以上是关于powershell 自动连接到RDP客户端的主要内容,如果未能解决你的问题,请参考以下文章

检查是不是通过 Powershell 远程启用了 CredSSP

无法通过 RDP 连接到 Windows 服务器 [关闭]

Ubuntu remmina无法连接到RDP服务器

加入 *** 后 AWS RDP 断开连接 [关闭]

为什么无法通过Google Cloud Platform上的Chrome RDP连接到Windows VM?

RDP 协议应用分析