We help IT Professionals succeed at work.

Powershell and sid history

zanderkid
zanderkid used Ask the Experts™
on
Currently we are using the following script to move users via intraforest from servera to server b.  I need a way to transfer the sid history from server a to server b as well.  

$GroupNames = Get-QADMemberOf "Username" -Service "domainA.com" | Select-Object -ExpandProperty Name
admt user /N "Username" /IF:YES /MGS:NO /SD: "domainA.com" /TD: "domainB" /TO:"server users" /UUR:YES /PO:Complex /FGM:YES
$GroupNames | ForEach-Object { Add-QADGroupMember $_ -Member "username" -Service "domainB" }
I found the following script online but do not know how to integrate it into the script to move the users.
function Add-SidHistory {
  Param($sourceDC,$sourceDomain,$sourceUsername,$targetDC,$targetDomain,$TargetUsername)
  $clonePrincipal = New-Object -COMObject DSUtils.ClonePrincipal
  $clonePrincipal.Connect($sourceDC,$sourceDomain,$targetDC,$targetDomain)
  $clonePrincipal.AddSidHistory($sourceUsername,$targetUsername,0)
  }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
PowerShell Developer
Top Expert 2010
Commented:
Not if DsUtils can't do it, and the documentation doesn't say that it can. Writing to that field is a highly privileged operation which is why you have to use things like DsUtils or ADMT and so on.

Chris