Verify Term store access

08/01/2012 19:32

#Verify access to termstore by follownig steps

#SecurityTokenApplication Pool is running
#Managed Metadata Service is running
#Termstore is set as default

#verify if user running script is
    #Farm Administrator in CA
    #Local Administrator
    #Site Collection Administrator
    #Termstore Administrator
    #Termstore owner
#input parameters



#Add user to Farm Administrators Group
$CAurl=$siteUrl  + ":" + $CAPort

#create a website object:
    $site = new-Object Microsoft.SharePoint.SPSite($CAurl)
    $web = $site.RootWeb
    #get the Farm administrators group:
    $farmadministrators = $web.SiteGroups["Farm Administrators"]
    #check if user is in Farm administrators group
   foreach ($user in $farmadministrators.users)
    #Write-Host $user
    if($user -eq $userName)
            write-host "User " $user " is already in Farm administrators group."
    if(-Not $isAdmin)
        #add the user to the Farm administartor group:
        write-host "User " $userName " is not in Farm administrators group."
        write-host "Adding..."
        $farmadministrators.AddUser($userName,"","New Sharepoint Farm Admins","")
        Write-Host "Succesfully added " $userName " to the Farm administrator group on the CA site: " $CAurl
    write-error $_

    #dipose everything:


#Add user to Term Store Administrators group
$AdminName = $userName
$taxonomySession = Get-SPTaxonomySession -Site $siteUrl
$termStore = $taxonomySession.TermStores[0]

if($termStore -ne $null)

    # Removing all the existing TermStore Administrators
    foreach($admin in $termStore.TermStoreAdministrators)



     #Adding new term Store Administrator
    $group = $termStore.Groups["avd Group"]

    if($group -ne $null)

            #Updating Owner of all the term set.                   
            foreach($termSet in $group.TermSets)

                    $termSet.Owner = $AdminName;




#Add user to site collection Administrators
  Add-SPShellAdmin $userName
  Set-SPSite -Identity $siteUrl -SecondaryOwnerAlias $userName
  #add users od jakuba
    Write-host 'Adding users'
    $site=Get-SPSite -Identity $siteUrl
    $web = $site.RootWeb
    $owners = $web.SiteGroups["Guided buying Owners"]