Last active
November 12, 2020 20:07
-
-
Save joerodgers/85b9f5a48804718ea850eee91c7bd773 to your computer and use it in GitHub Desktop.
Generates the metalogix xml file using the raw LoginName and Email values for users stored in the target SharePoint site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell | |
function ConvertTo-MetalogixUserMappingXml | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][object[]]$Mapping | |
) | |
begin | |
{ | |
$xml = New-Object System.Text.StringBuilder | |
$xml.AppendLine( "<Mappings>" ) | Out-Null | |
} | |
process | |
{ | |
foreach( $map in $Mapping ) | |
{ | |
$xml.AppendLine( "<Mapping Source=`"$($Mapping.Source)`" Target=`"$($Mapping.Target)`" />" ) | Out-Null | |
} | |
} | |
end | |
{ | |
$xml.AppendLine( "</Mappings>" ) | Out-Null | |
return $xml.ToString() | |
} | |
} | |
Get-SPSite -Identity "https://sharepoint.2016.contoso.com/sites/teamsite" | | |
SELECT -ExpandProperty RootWeb | | |
SELECT -ExpandProperty SiteUsers | ? { -not [string]::IsNullOrEmpty($_.Email) } | | |
SELECT @{Name="Source"; E={ $_.UserLogin}}, @{Name="Target"; E={$_.Email}} | | |
ConvertTo-MetalogixUserMappingXml | | |
Set-Content -Encoding UTF8 -Path "MappingFile_$(Get-Date -Format FileDateTime).xml" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment