Closed
Description
I'm looking for a way to do sudo-like privilege elevation. Administrators are not allowed to login, so as a regular user I need a way to become Administrator to do privileged actions, in the same ssh session. I've written down a way with Powershell here:
https://raymii.org/s/tutorials/SSH_on_Windows_Server_2019.html#sudo
$Username = 'Administrator'
$Password = 'P@ssw0rd'
$Pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$Pass
Enter-PSSession -ComputerName localhost -Credential $Cred
Example output:
[localhost]: PS C:\Users\Administrator\Documents> whoami
win-doipgfhik47\administrator
But that is not as easy as just "sudo". What is the correct way to do privilege elevation?