If you migrate a Sharepoint Farm into a new domain and use the STSADM -o migrategroup command it does not update the name attribute. The LoginName attribute will be correctly updated. The following Powershell script was written to address this.
The script only updates the display name of the groups, does not alter any security permissions and only looks for Domain Groups with "OLDDOMAINNAME\" in the name attribute.
The script copies the Domain Group LoginName attribute and replaces the name attribute with that value.
The script accepts a URL parameter and will get the web application for the URL you pass in and iterate all the sites in that web application.
[Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=71e9bce111e9429c")
#enter a site URL
$siteUrl = Read-Host "Enter Site URL"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
# Get the web application for that site URL
$spWebApp = $rootSite.WebApplication
# Iterate the sites for the web application
foreach($site in $spWebApp.Sites)
{
# Iterate the users/groups for that site
$group = $site.RootWeb.SiteUsers
foreach ($grp in $group)
{
# Ensure the item is a domain group
if($grp.IsDomainGroup -eq "True")
{
$groupname = $grp.name
if($groupname.Contains("OLDDOMAINNAME\"))
{
$grp.name = $grp.LoginName
$grp.Update()
$outputText = "$spaceBuffer$BUFFER_CHARS<Group>" + $grp.LoginName + " --Updated"
Write-Output $outputText
}
}
}
}
No comments:
Post a Comment