Last active
October 22, 2018 01:31
-
-
Save ryannewington/286d311a0755eec58d3f6f5591b6c3c9 to your computer and use it in GitHub Desktop.
Creates an administrator in the FIM/MIM service from an existing AD account
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
# Username of the user to add | |
$username = "ryan" | |
# Domain of the user to add | |
$domain = "lithnet" | |
# Display name to set in the portal | |
$displayName = "Admin-Ryan Newington" | |
Import-Module LithnetRMA | |
Set-ResourceManagementClient -BaseAddress localhost -Credentials (Get-Credential) | |
$objUser = New-Object System.Security.Principal.NTAccount($domain,$username) | |
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) | |
$bytes = New-Object byte[] $strSID.BinaryLength | |
$strSID.GetBinaryForm($bytes, 0) | |
# Create the resource | |
$o = New-Resource -ObjectType Person | |
$o.AccountName = $username | |
$o.Domain = $domain | |
$o.DisplayName = $displayName | |
$o.ObjectSID = $bytes | |
Save-Resource $o | |
# Add to administrators set | |
$set = Get-Resource Set DisplayName Administrators | |
$set.ExplicitMember.Add($o) | |
Save-Resource $set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment