janikvonrotz
6/1/2015 - 8:44 AM

Add Remote Desktop User #PowerShell #Windows

Add Remote Desktop User #PowerShell #Windows

$computername = "hostname"

Invoke-Command -ComputerName $computername -ScriptBlock { 
    $computer = $env:COMPUTERNAME
    $domain = "domain"
    $user = "username"
    $group = [ADSI]"WinNT://$computer/Remote Desktop Users,group"
    $group.psbase.Invoke("add",([ADSI]"WinNT://$domain/$user").Path) 
}