I am logging into a Windows Server 2016 box on GCP via SSH. That leaves me logged into a powershell session, but I need to have Admin privileges to successfully run some commands. I do not have another Admin account, so I basically need to elevate the current session somehow, start a new shell as admin, or find a way of running commands as myself elevated to admin status.
I know about the runas
command, but I can only see ways of running as other users, not myself elevated into the admin role. I basically want sudo
for Windows :)
Bear in mind that I cannot solve this issue using something that requires a normal UAC prompt, as that prompt needs to be handled using a mouse/keyboard in a graphical environment (typically RDP).
runas
is not applicable and theelevate
3-rd party command does not seem to work. The answer here might be that this is not possible due to a limitation in how UAC works, but I have not gotten such a response.Start-Process powershell -Verb runas
from a powershell session? Orpowershell -NoProfile -Command "& {Start-Process -FilePath powershell -Verb runas}"
out of it?.ssh/authorized_keys
, and giving permission to this file correctly then everything suddenly worked fine. Before this, I was using an id and password connection.