Add site collection administrators

21/11/2013 12:19

$admins = @("testuser", "lukas", "peter")

$site = Get-SPSite -Identity $siteUrl

 

foreach($admin in $admins)

{

    $userName = $env:UserDomain + "\" + $admin

    "Adding '{0}' to site collection administrators" -f $userName

   

    $user = $site.RootWeb.EnsureUSer($userName)

    $user.IsSiteAdmin = $true

    $user.Update()

   

}

 

$site.Dispose()