Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created May 22, 2014
Embed
What would you like to do?
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