In this article we will be seeing how to remove AD mapping from a user property in
SharePoint 2010 using PowerShell.
AD mapping in SharePoint 2010
We can map an AD property to user property so that the value for the user property
will be imported from AD in SharePoint 2010 from Central Administration.
Go to Central Administration => Application Management => Manage Service
Applications => User Profile Service Application.
![RmADShare1.gif]()
Click on Manage User Properties
![RmADShare2.gif]()
Click on the User property and then click on Edit in the ECB menu. You could see
the user property is mapped to one of the AD property.
![RmADShare3.gif]()
Automation: Remove AD mapping from a user property in SharePoint 2010 using
PowerShell
Here we will be seeing how to remove AD mapping from user property in SharePoint
2010 using PowerShell.
Steps Involved:
- Create the input xml file which contains
the inputs for removing AD mapping from user property.
- Create ps1 file which contains the script
for removing AD mapping from user property.
RemoveADMapping.xml
<?xml
version="1.0"
encoding="utf-8"
?>
<RemoveADMapping>
<SiteURL>http://serverName:8080/</SiteURL>
<ADProperty
Name="manager"
ConnectionName="Domain
Users" ></ADProperty>
</RemoveADMapping
>
RemoveADMapping.ps1
#----------------Get
the xml file---------------------------------------------------------------
[xml]$xmlData=Get-Content
"C:\Users\Desktop\ContentSources\RemoveADMapping.xml"
#----------------Create
new custom User Profile section---------------------------------------------
function
RemoveADMapping()
{
$site = Get-SPSite $xmlData.RemoveADMapping.SiteURL
$context = Get-SPServiceContext($site)
$upcm = New-Object
Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
$cm = $upcm.ConnectionManager
$Deployment.UserProfileProperties.RemoveADMapping.ADProperty | ForEach-Object{
$connection = $cm[$_.ConnectionName]
if($connection -ne $null)
{
$pm = $connection.PropertyMapping[$_.Name];
if($pm -ne $null)
{
$pm.Delete();
}
else
{
Write-Host -f Yellow "AD Property" $_.Name " is not mapped to
any user property"
}
}
else
{
Write-Host -f Yellow $_.ConnectionName " does not exists"
}
}}
#----------------Calling the
function---------------------------------------------
RemoveADMapping
Run the Script:
-
Go to Start.
-
Click on All Programs.
-
Click on Microsoft SharePoint 2010 Products
and then click on SharePoint 2010 Management Shell.
-
Run the C:\Users\Desktop\ContentSources\RemoveADMapping.ps1
And in the Central Administration you could edit
and see the user property, the AD property mapping will be removed from the user
property.