Windows 10: login and start local Desktop session remotely - windows

I have Windows 10 machine with monitor. There is a user with name Admin. It has full Administrators rights.
I can login as Admin locally using password and get the Desktop on the monitor. I can login as Admin via RDP and get Remote Desktop. Also I can login as Admin remotely via SSH and get CLI (PowerShell console for example).
So what I want to get more? I need to start the local Desktop remotely. But not via RDP! I want to do it from CLI.
The scenario: some person sits near the Windows 10 machine and waits. I execute script via SSH/PowerShell, and local Desktop session starts. Person gets Desktop on the monitor.
Is it possible?

Related

WIndow's ssh service defaults to admin permission

Connecting remotely into a windows machine using the OpenSSH service provided by windows always starts an elevated session.
Is it possible to start a non elevated session and elevate after the fact? if so how?
Based on this github discussion: https://github.com/PowerShell/Win32-OpenSSH/issues/1652
bagajjal:
For admin users, ssh connection is an elevated session. Given you are
an admin and has elevated session, you can write to c:\windows.
This is by design.
jborean93:
The biggest issue when you were to use the limited token after an SSH
logon is that you cannot then get your elevated token. On an
interactive logon you can right click and say Run as administrator and
confirm through the UAC prompt but on a network logon like SSH there
is no way for UAC to prompt you. So if this was a functionality you
will never be able to swap from the limited to full token of your
admin account.

Can I programmatically check a remote computer to see if someone is already connected via Remote Desktop to this computer?

We have a few Windows 10 Pro computers with Remote Desktop enabled. There are "client" machines running Windows 10 Pro and Windows 10 Home.
Is it possible to programmatically check, from a client machine, that the remote computer is already occupied by someone? That is, if another remote client is already connected to it? If so, can I do this without breaking the existing remote connection?
When a user logs on to a Remote Desktop Services–enabled computer, a
session is started for the user. Each session is identified by a
unique session ID. Because each logon to a Remote Desktop Connection
(RDC) client receives a separate session ID.
Refer: Remote Desktop Sessions
You can use the WTSEnumerateSessions function to retrieve the identifiers of all sessions on a specified RD Session Host server.
WTSEnumerateSessions : Retrieves a list of sessions on a Remote Desktop Session Host (RD
Session Host) server.
Note:
To enumerate a session, you must enable the query information
permission. For more information, see Remote Desktop Services
Permissions.
To change permissions on a session, use the Remote Desktop Services
Configuration administrative tool.
To enumerate sessions running on a virtual machine hosted on a RD
Virtualization Host server, you must be a member of the
Administrators group on the RD Virtualization Host server.
If you want to retrieve the session ID of the current session that the remote desktop service is running, you can call WTSQuerySessionInformation and specify WTS_CURRENT_SESSION for the SessionId parameter and WTSSessionId for the WTSInfoClass parameter.
You can use the query session command from the command line.
If you're on the same local network as the remote computer, then you can directly use the query session:
Use the command query session /SERVER:<remote pc name, or IP address>
If there is someone actively logged into the console, then it returns console <username> Active as the state. However, this can also mean someone logged in, the session locked, and they walked away for coffee. It doesn't actually mean they are doing something in the session; they are simply logged into the console. This state also occurs if you use another remote login software such as TeamViewer, since it logs in as an active console.
C:\Users\Myself>query session /server:LabServerPC
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
console LabUser 1 Active
rdp-tcp 65536 Listen
If the computer is already in use by a remote desktop session, it will return it as a session as the active state. In this case rdp-tcp#1 <username> Active.
C:\Users\Myself>query session /server:LabServerPC
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
rdp-tcp#1 LabUser 1 Active
console 3 Conn
rdp-tcp 65536 Listen
If you are operating via a VPN, or off the native network, it may be easier to remotely log into the PC using SSH and then query the session directly. In this case, you would use query session only.

Creating user in Windows Server 2016

I have a remote Windows server 2016. With RDP I can login to the server as an Administrator.
I created a new user with Admin rights and also with Remote access enabled. But I am unable to login via RDP with the new user.
I have created the user via Computer Managment-> Users and Groups
The created user should also be added to the Remote Desktop Users Group so as to give the users permission to access the machine remotely.

Set up security group for Windows Instance in AWS

I'm trying to connect my machine (MacOS) to a remote. I went on AWS and create a windows instance, I use the default security groups and downloaded the rdp file.
I open it with Microsoft Remote Destock and ends up with an error message:
Unable to connect to remote PC. Please verify Remote Desktop is enabled, the remote PC is turned on and available on the network, and then try again.
I tried to run the rdp file on a windows machine, I got the same error.
My question is: How do we set the security groups to open windows remotely.
Thanks
check your security group and make sure you have open RDP(3389)port.
Then you can generate your password by.
EC2 console --> Connect To Your Instance --> Get Password --> Choose Browse and navigate to the private key file --> Decrypt Password.
The console displays the default administrator password for the instance in the Connect To Your Instance dialog box.
If you want to generate Remote Desktop File or details information you can go throught below link. https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2_GetStarted.html

Scheduled Task for script vs Direct Execute: issues

I have a VBscript file which connects to remote computers over our network and initiates a WBEM-Scripting method. I can open a CMD console using the credentials for a domain user account which has local admin rights on all of our desktop computers, and the script performs as desired.
I created a scheduled task on a Windows Server 2003 member server which runs the same script file using the same credentials, but it fails to connect to the WMI provider on remote computers.
The desktops are all Windows 7 SP1 and the domain is Windows Server 2008 level (forest and domain).
The domain user account was added to the local administrators group on the server, and was granted "Logon as a service" rights via Group Policy.
Question: Is there something else I'm missing that could be causing the scheduled task to fail while the interactive execution works fine?
I've had this same problem happening (scripts do not run as schedule tasks but, executable files do). You can get around this by doing the following:
There is a Start in (Optional) text box below the Program/Script text box on the property page for the Actions Tab. Fill it to include the path of your script So if your script is at c:\users\user\desktop\script.vbs, the text boxes will look like this:
Program/Script:
c:\users\user\desktop\script.vbs
Add Arguments (Optional)
Start in (Optional) c:\users\user\desktop

Resources