Skip to main content
Get-UserAndGroupMapping

Get your user mappings for a specified source and destination SharePoint site with PowerShell

Updated over a month ago

Command

Get-UserAndGroupMapping

Description

The command to get the user and group mappings from a source site and a destination site.

Examples

Get mappings from a source site and a destination site

# Connect to the source and destination sites
$srcSite = Connect-Site -Url "http://myfarm1/sites/mysourcesite"
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"

# Retrieve and display the current user and group mapping settings
$mappingSettings = Get-UserAndGroupMapping -SourceSite $srcSite -DestinationSite $dstSite
$mappingSettings

# Output:
# PropertyMappings :
# ContentTypeMappings :
# UserAndGroupMappings : CustomPermissions Members -> Sales&Marketing Owners
# i:0#.w|office\sg.achille -> i:0#.w|office\sg.baptiste
# i:0#.w|office\sg.camille -> i:0#.w|office\sg.denis
# PermissionLevelMappings :
# SiteTemplateMappings :

Get mappings from the file system and a destination site

# Connect to the destination site
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"

# Retrieve user and group mappings from the file system, applying them to the destination site
$mappingSettings = Get-UserAndGroupMapping -FromFileSystem -DestinationSite $dstSite

# Display the retrieved mapping settings
$mappingSettings
# Output:
# PropertyMappings :
# ContentTypeMappings :
# UserAndGroupMappings : OFFICE\Employee -> Sales&Marketing Owners
# OFFICE\sg.achille -> i:0#.w|office\sg.baptiste
# OFFICE\sg.camille -> i:0#.w|office\sg.denis
# PermissionLevelMappings :
# SiteTemplateMappings :

Merge mappings with mappings from a source site and a destination site

# Set up the user and group mapping
$mappingSettings = Set-UserAndGroupMapping -Source "John Doe" -Destination "Paul Smith"

# Update the mapping to include "myusername" -> "anotherusername"
$mappingSettings = Set-UserAndGroupMapping -MappingSettings $mappingSettings -Source "myusername" -Destination "anotherusername"

# Map unresolved users or groups to "Old employee Group"
$mappingSettings = Set-UserAndGroupMapping -MappingSettings $mappingSettings -UnresolvedUserOrGroup -Destination "Old employee Group"

# Connect to source and destination sites
$srcSite = Connect-Site -Url "http://myfarm1/sites/mysourcesite"
$dstSite = Connect-Site -Url "http://myfarm1/sites/mydestinationsite"

# Retrieve the updated user and group mapping with site context
$mappingSettings = Get-UserAndGroupMapping -MappingSettings $mappingSettings -SourceSite $srcSite -DestinationSite $dstSite

# Display the final mapping settings
$mappingSettings
# Output:
# PropertyMappings :
# ContentTypeMappings :
# UserAndGroupMappings : <Unresolved users or groups> -> Old employee Group
# CustomPermissions Members -> Sales&Marketing Owners
# i:0#.w|office\sg.achille -> i:0#.w|office\sg.baptiste
# i:0#.w|office\sg.camille -> i:0#.w|office\sg.denis
# John Doe -> Paul Smith
# myusername -> anotherusername
# PermissionLevelMappings :
# SiteTemplateMappings :

Syntax

Get-UserAndGroupMapping-SourceSite <Site> -DestinationSite <Site> [-MappingSettings <MappingSettings>]
Get-UserAndGroupMapping-FromFileSystem <SwitchParameter> -DestinationSite <Site> [-MappingSettings <MappingSettings>]

Parameters

-DestinationSite <Site>

Specifies the destination site.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-FromFileSystem <SwitchParameter>

Specifies that the source is the file system.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

FileSystem

Aliases

None

-MappingSettings <MappingSettings>

Specifies the mapping settings.

Required?

False

Default value

None

Accept pipeline input?

True (ByValue, ByPropertyName)

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-SourceSite <Site>

Specifies the source site.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Default

Aliases

None

Did this answer your question?