Scripts/RemoteDesktop.ps1


function IsMemberOfRemoteDesktopUserGroup()
{
    <#
    .SYNOPSIS
    Whether the user is member of the "Remote Desktop Users" group.
    Such a user is granted the right to logon remotely.
    #>

    return (Get-LocalGroup | Where-Object { $_.SID -eq "S-1-5-32-555" }).Count -gt 0
}

function RemoteDesktopConnect([string]$target)
{
    <#
    .SYNOPSIS
    Connects to the given target computer via remote desktop.
    The given target may be an IP address or a hostname.
    #>

    
    # https://ss64.com/nt/mstsc.html
    $mstscExe = "$env:windir\system32\mstsc.exe"
    Start-Process $mstscExe -ArgumentList "/v:$target"
}