0

We are planning to move a content database to another SharePoint farm in another domain and I anticipate that users might not be able to access the site in the new domain because of the change in the domain for example: old domain is FH\ and new domain is pk.

Will this be the case and if so:

  • Is there a script stsadm and/or PowerShell to update the domain attribute of all users in SharePoint?

  • I know of Move-SPUser, but that only applies to users individually, is there a script that can apply to all users?

    • For example, I want to change all user from fg\ domain to rw\ domain
0

You can do it, if you extract the all user in the cvs then you can run the migrate user command against that CSV file.

here is the script which required a CSV file.

# Required parameters. 
param (  
    [Parameter(Mandatory = $true)]  
    [string]$InputCSVFile = "", 
    [Parameter(Mandatory = $true)]  
    [string]$WebAppUrl = "" 
    )  

# Add Microsoft SharePoint PowerShell pssnapin. 
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue 

# Import all current and new user accounts. 
Import-Csv $InputCSVFile -Delimiter ","  |  

%{ 
    Try 
        { 
        # Get and create a user object by current user account. 
        Write-Host "Getting current user object by " -NoNewline 
        Write-Host -ForegroundColor Yellow $_.CurrentUser"..." 
        $user = Get-SPUser -web $WebAppUrl -Identity $_.CurrentUser -ErrorAction Stop 

        # Create new alias by new user account. 
        Write-Host "Creating new alias by " -NoNewline 
        Write-Host -ForegroundColor Yellow $_.NewUser "..." 
        Move-SPUser -Identity $user -NewAlias $_.NewUser -IgnoreSID -Confirm:$false -ErrorAction Stop 
        Write-Host -ForegroundColor Green "The new alias has been created." 
        } 
    Catch [Exception] 
        { 
        # Return error message. 
        return $_.exception 
        } 
}
0

Many thanks for response.

In search of a simpler solution I found this solution. Please could you confirm if the below solution can be used

Set-ExecutionPolicy RemoteSigned -Force
$site = New-Object Microsoft.SharePoint.SPSite("http://sp2007")
$web = $site.OpenWeb()
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

$web.SiteUsers | ? {
  $_.LoginName -like 'domainold\*' 
} | % {
  $oldLogin = $_.LoginName
  $newLogin = $_.LoginName.ToLower().Replace('domainold\', 'domainnew\')
  $farm.MigrateUserAccount($oldLogin, $newLogin, $false) 
}`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.