Writing ms-DS-ConsistencyGUID to AD-users in decimal
Solution 1:
Both objectGUID
and ms-Ds-ConsistencyGuid
are stored as type System.Byte[]
(click on the row containing Syntax=Object(Replica-Link)).
If you query the attributes via PowerShell, then objectGUID
is retrieved as type Guid
and ms-Ds-ConsistencyGuid
as System.Byte[]
You have two options.
- Convert the
Guid
toSystem.Byte[]
and store it in thems-Ds-ConsistencyGuid
attribute of the new user object as follows:
$olduser = Get-ADUser olduser
Set-ADUser newuser -Replace @{ "ms-Ds-ConsistencyGuid" = $olduser.ObjectGUID.ToByteArray() }
- Import the GUID from a csv as string, convert it to a Guid and then to
System.Byte[]
and store it in thems-Ds-ConsistencyGuid
attribute of the new user object as follows:
$guidString = "41a1d9c1-239f-4663-b3fb-82d7f29a0d1c"
$guid = [guid]$guidString
$guidByteArray = $guid.ToByteArray()
Set-ADUser newuser -Replace @{ "ms-Ds-ConsistencyGuid" = $guidByteArray }