Skip to content

Instantly share code, notes, and snippets.

@mattwoolnough
Created July 4, 2016 00:01
Show Gist options
  • Save mattwoolnough/2d0854dc8750569c9f97929b7b47b6f6 to your computer and use it in GitHub Desktop.
Save mattwoolnough/2d0854dc8750569c9f97929b7b47b6f6 to your computer and use it in GitHub Desktop.
# Username of the user to add
$username = "svc_fim_service"
# Domain of the user to add
$domain = "FIMDev"
# Display name to set in the portal
$displayName = "FIM Service Service Account"
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 = $accountName
$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