Public/Add-LocalAdmin.ps1

function Add-LocalAdmin {
    <#
    .SYNOPSIS
    -Taylor Lee
    Modified 07162019
 
    .DESCRIPTION
    This function adds a local admin to the computer or server it is run from.
 
    .PARAMETER User
    The user that is to be added as a local admin
 
    .NOTES
    Azure AD Joined machines will require the user to first login to a computer with their domain account before adding their domain account as a local admin.
    The user logging in registers their SID so that the command is succesful.
 
    .EXAMPLE
    Adds specified domain user to the local administrators group
 
    Add-LocalAdmin -user domain\user
 
    .Link
    https://github.com/TheTaylorLee/AdminToolbox
    #>


    [CmdletBinding()]

    Param (
        [Parameter(Mandatory = $true)]$user
    )

    #Check For Admin Privleges
    Get-Elevation

    net.exe Localgroup Administrators $user /add

}