Created
March 4, 2020 13:45
-
-
Save markhallen/2875df3cc62bf4bdf88808c53f42340f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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