You might encounter the need to create a local user, add it to the local admins remotely. Being if the user cannot log in or the local admin is lost.
For the purpose you need to use PSTools which can be downloaded from here.
Once downloaded open a command prompt as Administrator from the server or a machine logged in with a domain administrator and type
PSEXEC \\computername NET USER localadmin <pass> /add
PSEXEC \\computername NET LOCALGROUP Administrators localadmin /ADD
localadmin being the username you wish to use and the <pass> is the user’s password.
(5983)
After joining a computer to AzureAD you will login with a user and will be automatically added as a local admin. The trouble is when logging with other users. These users will automatically set as users to the computer. From the Computer Management Console there is no way to add an AzureAD as when you click on Add and Locations, there is no location for the AzureAD. If you look at the current AAD user in the Computer Management and Local Users and Groups you will find the current user as AZUREAD\noel.pulis.
Luckily there is a way to add an additional AzureAD user as a local admin.
– Open CMD (Command Prompt) as Admin
– Type NET Localgroup Administrators AzureAD\additionaluser /add

Once this is ready, open the Local Users and Groups and you will find the AzureAD user part of the local Administrators Group.
(6335)
Technical help and scripts for everyday issues of a sysadmin day