Uno script di esempio in PowerShell per migrare a claims tutti i gruppi windows che non sono stati convertiti

PowerShell

#migra a claims tutti i GRUPPI windows che non sono stati convertiti

$url ="http://sharepoint.sgart.local"

$ErrorActionPreference = "Stop"
Get-Date >> migrate.txt
Get-Date >> errori.txt
	$v=@{}

#http://thepowershellguy.com/blogs/posh/archive/2007/01/23/powershell-converting-accountname-to-sid-and-vice-versa.aspx
function ConvertTo-Sid ($NtAccount) {
(new-object system.security.principal.NtAccount($NTaccount)).translate([system.security.principal.securityidentifier])
}

Get-SPSite -WebApplication $url -limit all | foreach {
	Write-Host $_.url -ForegroundColor green
	$users = get-spuser -web $_.url -Limit ALL
	foreach($useriteration in $users)
	{
		if($useriteration.IsDomainGroup -eq $false) {
			continue
		}

		$title = $useriteration.Name
		$userlogin = $useriteration.UserLogin

		if($userlogin -match "c:0.*") {
			continue
		}

		if($v.Contains($userlogin) -eq $false){
			$v.Add($userlogin, $title);
		
		}

		#Write-Host "$userlogin - $title"  -ForegroundColor DarkMagenta
		try {
			Write-Host "try $userlogin"
			#c:0+.w|s-1-5-21-1832937852-2116575123-337272265-207073

		$userlogin = $userlogin.Replace("i:0#.w|", "")

			$sid = (ConvertTo-Sid $userlogin).Value.ToLower()
			$al = "c:0+.w|$sid"
			Move-SPUser -IgnoreSID -Confirm:$false -Identity $useriteration -NewAlias $al 
			# Log
			Write-Host "converted group $al" -ForegroundColor yellow
			$userlogin >> migrate.txt
read-host "Premi un tasto"
		} catch {
			Write-Host $userlogin  -ForegroundColor red
			$userlogin >> errori.txt
			continue;
		}
 	}
}
Get-Date >> migrate.txt
Get-Date >> errori.txt
#$v
Tags:
Installazione26 PowerShell200 SharePoint498 SharePoint 2007218 SharePoint 2010224
Potrebbe interessarti anche: