Skip to content

Instantly share code, notes, and snippets.

@ryannewington
Last active October 22, 2018 01:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryannewington/286d311a0755eec58d3f6f5591b6c3c9 to your computer and use it in GitHub Desktop.
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
# 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