Skip to content

Instantly share code, notes, and snippets.

@markhallen
Created March 4, 2020 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhallen/2875df3cc62bf4bdf88808c53f42340f to your computer and use it in GitHub Desktop.
Save markhallen/2875df3cc62bf4bdf88808c53f42340f to your computer and use it in GitHub Desktop.
<#
.SYNOPSIS
This script was created for use in ConfigMger Run Scripts
.DESCRIPTION
The Members
.PARAMETER Member
Specifies an array of users or groups that this cmdlet adds to a security group.
You can specify users or groups by name or security ID (SID).
.EXAMPLE
Add-LocalAdministrator.ps1 -Member 'domain\user'
#>
Param(
[Parameter(Mandatory=$true)]
[String]$Member
)
Write-Host "Attempting to add $Member to the local admins group"
try {
Add-LocalGroupMember -Group "Administrators" -Member $Member
}
catch {
Write-Host "Failed to add $Member to the local admins group"
Exit $LASTEXITCODE
}
Write-Host "Added $Member to the local admins group"
Exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment