远程桌面powershell指示

时间:2015-07-19 11:52:23

标签: powershell remote-desktop windows-server

我正在尝试自动化远程桌面进程(从Windows客户端到Windows服务器)以获取我正在处理的服务。
为此,我使用以下Powershell脚本:

$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$Process = New-Object System.Diagnostics.Process

$ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe"
$ProcessInfo.Arguments = "/generic:TERMSRV/$ComputerCmdkey /user:$User /pass:$Password"
$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
$Process.StartInfo = $ProcessInfo
if ($PSCmdlet.ShouldProcess($ComputerCmdkey,'Adding credentials to store')) {
       [void]$Process.Start()
}

$ProcessInfo.FileName = "$($env:SystemRoot)\system32\mstsc.exe"
$ProcessInfo.Arguments = "$MstscArguments /v $Computer"
$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Normal
$Process.StartInfo = $ProcessInfo
if ($PSCmdlet.ShouldProcess($Computer,'Connecting mstsc')) {
    [void]$Process.Start()
}

这个脚本运行得很好。我缺少的是客户端上的指示(除了UI窗口 - 一些返回值或事件日志),可以告诉我连接是成功还是失败。
这里的任何人都可以帮忙吗? 感谢

0 个答案:

没有答案
相关问题