This script adds one or more users to local Administrators group on one or more computers. For more details see this post.

To use it, download it, unblock the file, run it in Powershell_ISE for example to load  the function, and use it as in:

PowerShell
Edit|Remove
help Add-Admin -Full
Powershell displays help output like:
NAME
    Add-Admin
    
SYNOPSIS
    Function to add local or domain user(s) to local Administrators group on one or many computers
    
SYNTAX
    Add-Admin [-ComputerName]  [-NewAdmin]  [[-NewAdminPassword] ] [[-CurrentAdmin] ] [[-LogFile] ] [-WhatIf] [-Confirm] 
    []
    
DESCRIPTION
    Function to add local or domain user(s) to local Administrators group on one or many computers.
    The script uses ping/ICMP to check if target computer(s) are online. If response to ping/ICMP 
    is disabled on a target computer, the script will skip it.
    The script logs steps taken and results in a log file.

PARAMETERS
    -ComputerName 
        Computer name(s) where the script will add local admin account
        
        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue, ByPropertyName)
        Accept wildcard characters?  false
        
    -NewAdmin 
        New user name(s) to be made member of the Administrators group on target computer(s)
        This can be a domain user account such as "domain\user", 
        or a local user account like "newadmin"
        If a local user account is specified and it did not exist, the script will create it.
        If a domain user account is specified and it did not exist, the script will NOT create it.
        
        Required?                    true
        Position?                    2
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -NewAdminPassword 
        New user password to be setup as local admin on target computer(s)
        Must meet minimum password complexity on each computer in'ComputerName'. 
        This will be saved to the log file (clear text).
        If absent, script assumes "Temp-Pass5"
        If adding a domain user to local Administrators group, this parameter is ignored.
        
        Required?                    false
        Position?                    3
        Default value                Temp-Pass5
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -CurrentAdmin 
        This can be an existing local admin account on the PCs or domain admin like "MyDomain\MyAdmin"
        This defaults to the account running this script
        
        Required?                    false
        Position?                    4
        Default value                "$env:USERDOMAIN\$env:USERNAME"
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -LogFile 
        Path to the file where the script will save its progress steps
        
        Required?                    false
        Position?                    5
        Default value                ".\Add-Admin_$(Get-Date -format yyyyMMdd_hhmmsstt).txt"
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -WhatIf []
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -Confirm []
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see 
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 
    
NOTES
        Function by Sam Boutros
        v2 - 11/09/2014
    
    -------------------------- EXAMPLE 1 --------------------------
    
    C:\PS>Add-Admin -ComputerName V-2012r2-vbr1 -NewAdmin Sam7
    
    This creates a local user 'Sam7' on computer 'V-2012r2-vbr1', gives it 'Temp-Pass5' password
    and makes it a member of the local Administrators group
    
    -------------------------- EXAMPLE 2 --------------------------
    
    C:\PS>Add-Admin -ComputerName V-2012r2-vbr1,NoThere -NewAdmin Sam8 -NewAdminPassword New33One!!
    
    This creates a local user 'Sam8' on computers 'V-2012r2-vbr1' and 'NoThere', 
    gives it 'New33One!!' password,
    and makes it a member of the local Administrators group
    
    -------------------------- EXAMPLE 3 --------------------------
    
    C:\PS>Add-Admin -ComputerName (Get-Content ".\computerlist.txt") -NewAdmin Sam9 -NewAdminPassword New33One!!
    
    This creates a local user 'Sam9' on each of the computers listed in the ".\computerlist.txt" file, 
    gives it 'New33One!!' password,
    and makes it a member of the local Administrators group
    
    -------------------------- EXAMPLE 4 --------------------------
    
    C:\PS>Add-Admin -ComputerName V-2012r2-vbr1 -NewAdmin domain\samb
    
    This adds domain user 'domain\samb' to the local Administrators group on 'V-2012r2-vbr1'
    
RELATED LINKS
    https://superwidgets.wordpress.com/category/powershell/