-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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