Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created May 22, 2014 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciphertxt/123298b389c9bcdb58c5 to your computer and use it in GitHub Desktop.
Save ciphertxt/123298b389c9bcdb58c5 to your computer and use it in GitHub Desktop.
Migrates users from a specified OU in Active Directory with Windows Claims identities to ACS identities
asnp Microsoft.SharePoint.Powershell -EA 0
Import-Module ActiveDirectory
$web = "https://www.contoso.com"
$windowsClaimPrefix = "i:0#.w|"
$acsClaimPrefix = "i:0e.t|acsidentifier|"
$domainPrefix = "contoso\"
$containerOU = "OU=Users,DC=contoso,DC=com"
Get-SPUser -Web $web -Limit All |
ForEach-Object {
if ($_.UserLogin.ToString().Contains($windowsClaimPrefix)) {
$currentSPLogin = $_.UserLogin.ToString().Replace($windowsClaimPrefix,"").Replace($domainPrefix,"")
#$mail = "*$($currentSPLogin)*"
if ($_.Email.Length -gt 0) {
$user = Get-ADUser -Filter { mail -eq $_.Email } -SearchBase $containerOU
if ($user) {
$newUserAlias = $acsClaimPrefix + $user.UserPrincipalName
Write-Output "Login: $($_.UserLogin)/UPN: $($user.UserPrincipalName)/New Alias:$($newUserAlias)"
$_ | Move-SPUser -NewAlias $newUserAlias -IgnoreSID -Confirm:$false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment