Verify Term store access
#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
$userName="avd-corp\l.sevcik"
$CAPort="16546"
$siteUrl="https://buyingportalint.dcs.avd.com"
#Add user to Farm Administrators Group
$CAurl=$siteUrl + ":" + $CAPort
try
{
#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
$isAdmin=$false
foreach ($user in $farmadministrators.users)
{
#Write-Host $user
if($user -eq $userName)
{
write-host "User " $user " is already in Farm administrators group."
$isAdmin=$true
}
}
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
}
}
catch
{
write-error $_
}
finally
{
#dipose everything:
$web.Dispose()
$site.Dispose()
}
#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)
{
$termStore.DeleteTermStoreAdministrator($admin.PrincipalName);
}
#Adding new term Store Administrator
$termStore.AddTermStoreAdministrator($AdminName);
$group = $termStore.Groups["avd Group"]
if($group -ne $null)
{
#Updating Owner of all the term set.
foreach($termSet in $group.TermSets)
{
$termSet.Owner = $AdminName;
}
}
}
$termStore.CommitAll();
#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"]
$owners.AddUser("avd-CORP\l.sevcik","","","")
$owners.AddUser("PWST\e-jozefe","","","")