private/start/Start-WindowsRemoteDesktop.ps1
function Start-WindowsRemoteDesktop { [CmdletBinding(PositionalBinding = $true)] [OutputType([System.Diagnostics.Process])] param( [Parameter(Mandatory = $true)] [int] $Port ) Write-Host 'Starting Windows Remote Desktop..' -ForegroundColor DarkMagenta try { $params = @{ FilePath = 'mstsc' ArgumentList = @("/v:localhost:$Port", '/prompt') NoNewWindow = $true Wait = $false PassThru = $true } $process = Start-Process @params return $process } catch { Write-Error "An error occurred starting Windows Remote Desktop. $_" throw } } |