From b5708c3cab412e26cf7f89840a9eeea62635bf88 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Fri, 28 Oct 2016 13:55:41 +0200 Subject: [PATCH] Removed bug in Connect-Mstsc --- Connect-Mstsc/Connect-Mstsc.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Connect-Mstsc/Connect-Mstsc.ps1 b/Connect-Mstsc/Connect-Mstsc.ps1 index 3933d23..db74287 100644 --- a/Connect-Mstsc/Connect-Mstsc.ps1 +++ b/Connect-Mstsc/Connect-Mstsc.ps1 @@ -193,9 +193,9 @@ An remote desktop session to server01 will be created using the credentials of c if ($Credential) { $User = $Credential.UserName - $Password = $Credential.GetNetworkCredential().Password + $UserPass = $Credential.GetNetworkCredential().Password } else { - $Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + $UserPass = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) } } process { @@ -211,7 +211,7 @@ An remote desktop session to server01 will be created using the credentials of c } $ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe" - $ProcessInfo.Arguments = "/generic:TERMSRV/$ComputerCmdkey /user:$User /pass:$Password" + $ProcessInfo.Arguments = "/generic:TERMSRV/$ComputerCmdkey /user:$User /pass:$UserPass" $ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden $Process.StartInfo = $ProcessInfo if ($PSCmdlet.ShouldProcess($ComputerCmdkey,'Adding credentials to store')) {