If you use ShareGate to do migrations one of the things you will notice is that you need to have a specific xml file called an SGUM file. The file maps the O365 users UPN to on-premise AD users login name. To do so, you will need a csv file of the mappings and the script below then outputs the list into the appropriate format.

DisplayName UserPrincipalName Mapping Mapping2
accounts payable accountspayable@democompany.com demo\accountspayable
accounts receivable accountsreceivable@democompany.com demo\accountsreceivable
Viney Bullo vbullo@democompany.com demo\vbullo
Will Bahern wbahern@democompany.com demo\wbahern
Yedah Johns yjohns@democompany.com demo\yjohns

SCRIPT BELOW
$dt = get-date -format “yyyyMMdd”
$path = “C:\Temp\DOT\UserMap_$dt.sgum”
$XmlWriter = new-object System.XML.XMLTextWriter($path, $null)
$XmlWriter.Formatting = ‘Indented’
$xmlwriter.Indentation = 1
$XmlWriter.IndentChar = “`t”
$csvpath = “C:\Temp\DOT\Consolidated_users.csv”
#write the header
$xmlWriter.WriteStartDocument()
$XMLWriter.WriteStartElement(‘UserAndGroupMappings’)
$XmlWriter.WriteAttributeString(‘xmlns:xsd’, ‘http://www.w3.org/2001/XMLSchema’)
$XmlWriter.WriteAttributeString(‘xmlns:xsi’, ‘http://www.w3.org/2001/XMLSchema-instance’)
$XMLWriter.WriteStartElement(“Mappings”)
$count = 0
import-csv $csvpath | foreach{
$displayname = $_.DisplayName
$upn = $_.UserPrincipalName
$map = $_.Mapping
$map2 = $_.Mapping2
$SourceAccountName = “i:0#f|membership|$upn”
$DestinationAccountName = “i:0#f|membership|$map”
$DestinationAccountName2 = “i:0#f|membership|$map2”
$DestinationDisplayname = $displayname
$SourceDisplayname = $displayname
if($map){
$count ++
$XMLWriter.WriteStartElement(“Mapping”)
$XMLWriter.WriteStartElement(“Source”)
$XmlWriter.WriteAttributeString(‘AccountName’, $SourceAccountName)
$XmlWriter.WriteAttributeString(‘DisplayName’, $SourceDisplayname)
$XmlWriter.WriteEndElement() #source
$XMLWriter.WriteStartElement(“Destination”)
$XmlWriter.WriteAttributeString(‘AccountName’, $DestinationAccountName)
$XmlWriter.WriteAttributeString(‘DisplayName’, $DestinationDisplayname)
$XmlWriter.WriteEndElement() #Destination
$XmlWriter.WriteEndElement() #mapping
}
if($map2){
$count ++
$XMLWriter.WriteStartElement(“Mapping”)
$XMLWriter.WriteStartElement(“Source”)
$XmlWriter.WriteAttributeString(‘AccountName’, $SourceAccountName)
$XmlWriter.WriteAttributeString(‘DisplayName’, $SourceDisplayname)
$XmlWriter.WriteEndElement() #source
$XMLWriter.WriteStartElement(“Destination”)
$XmlWriter.WriteAttributeString(‘AccountName’, $DestinationAccountName2)
$XmlWriter.WriteAttributeString(‘DisplayName’, $DestinationDisplayname)
$XmlWriter.WriteEndElement() #Destination
$XmlWriter.WriteEndElement() #mapping
}
}
$XmlWriter.WriteEndElement() #mappings
$XmlWriter.WriteEndElement() #UserAndGroupMappings
$xmlWriter.WriteEndDocument()
$xmlWriter.Flush()
$xmlWriter.Close()
Write-Host $count

This will output the following xml file:

Which can then be imported into ShareGate to map the internal existing users to the users in the cloud. Thus, when you do the migration of the content if a user posted something as demo\vbullo in the old site then the posted document metadata will show vbullo@democompany.com as the user of record.

But here is a question: What metadata is applied to documents that were posted to the old site before the user has left the business when they are migrated? The answer is that whatever user is doing the migration will show up as the unmapped user since the internal user cannot be resolved to a cloud user. You probably dont want your name appearing all over the place on documents just because the users have left employment so the fix for this is to add an unresolved user mapping. The first thing to do is to create a cloud only user, in this case “migrationmapper@democompany.onmicrosoft.com” to map the documents back to.

Next, You should add the following line right before the first <Mappings>;

<Unresolved AccountName=”i:0#.f|membership|migrationmapper@democompany.onmicrosoft.com” DisplayName=”Migration Mapper” PrincipalType=”User” />

In this way, any unresolved users will be mapped back to the account you already have set up.

We hope this helps in your ShareGate migration.

Live long and Prosper,

DM

Hits: 468