Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

USMT Script

Publié le par damcuvelier

Add-PSSnapin Microsoft.SharePoint.PowerShell
function MigrateUserOrGroups($migrationType, $csvFile)
{
   #Getting the SPFarm object
   $farm = Get-SPFarm
 
   Write-Host $migrationType
   #Checking whether the user input the type of Migration as Group
   if($migrationType -eq "Group"){
   Import-Csv $csvFile | ForEach-Object{
      Write-Host "Migrating Group" $_.oldlogin "to" $_.newlogin -ForegroundColor Green
      $farm.MigrateGroup($_.oldlogin, $_.newlogin)
 
       }
      }
 
    #Checking whether the user input the type of Migration as User
    if($migrationType -eq "User")
      {
 
        Import-Csv $csvFile | ForEach-Object{
        Write-Host "Migrating User" $_.oldlogin "to" $_.newlogin -ForegroundColor Green
        $farm.MigrateUserAccount( $_.oldlogin, $_.newlogin, $false )
        }      
      }
 
   Write-Host "Migration Completed" -ForegroundColor Cyan
 
 
   # $farm.Name
}
 
MigrateUserOrGroups $args[0] $args[1]

Commenter cet article