Create Managed Metadata Service Application (MMS) in SharePoint 2016 using PowerShell
Managed Metadata Service allows us to Centrally manage enterprise level metadata & Content Types to use between Site Collections, Web Applications even across farms. Creation of Managed Metadata Service in SharePoint 2016 provides us “Term Store,” which is a central repository to manage Terms. The Term Store allows administrators to add/update/delete Term Sets, Term Groups, and Terms.
Use the below PowerShell script to add a new managed metadata service application in SharePoint 2016. Change the configuration parameter values such as: Service Application name, application pool, database name, etc., accordingly.
PowerShell Script to Create Managed Metadata Service Application in SharePoint 2016:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration Parameters
$ServiceAppName = "Managed Metadata Service Application"
$ServiceAppProxyName = "Managed Metadata Service Application Proxy"
$AppPoolAccount = "Crescent\SP16-AppPool"
$AppPoolName = "Service Application App Pool"
$DatabaseServer ="SP16-SQL001"
$DatabaseName = "SP16_Service_MMS"
$ContentTypeHub="https://intranet.crescent.com/ctypehub"
Try {
#Set the Error Action
$ErrorActionPreference = "Stop"
#Check if Managed account is registered already
Write-Host -ForegroundColor Yellow "Checking if the Managed Accounts already exists"
$AppPoolAccount = Get-SPManagedAccount -Identity $AppPoolAccount -ErrorAction SilentlyContinue
if($AppPoolAccount -eq $null)
{
Write-Host "Please Enter the password for the Service Account..."
$AppPoolCredentials = Get-Credential $AppPoolAccount
$AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials
}
#Check if the application pool exists already
Write-Host -ForegroundColor Yellow "Checking if the Application Pool already exists"
$AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue
if ($AppPool -eq $null)
{
Write-Host -ForegroundColor Green "Creating Application Pool..."
$AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount
}
#Check if the Service application exists already
Write-Host -ForegroundColor Yellow "Checking if Managed Metadata Service Application exists already"
$ServiceApplication = Get-SPServiceApplication -Name $ServiceAppName -ErrorAction SilentlyContinue
if ($ServiceApplication -eq $null)
{
Write-Host -ForegroundColor Green "Creating Managed Metadata Service Application..."
$ServiceApplication = New-SPMetadataServiceApplication -Name $ServiceAppName -ApplicationPool $AppPoolName -DatabaseName $DatabaseName -DatabaseServer $DatabaseServer
}
#Check if the Service application Proxy exists already
$ServiceAppProxy = Get-SPServiceApplicationProxy | where { $_.Name -eq $ServiceAppProxyName}
if ($ServiceAppProxy -eq $null)
{
#Optional Parameters:
$ServiceApplicationProxy = New-SPMetadataServiceApplicationProxy -Name $ServiceAppProxyName -ServiceApplication $ServiceApplication -DefaultProxyGroup -ContentTypePushdownEnabled -DefaultKeywordTaxonomy -DefaultSiteCollectionTaxonomy -Uri $ContentTypeHub
}
#Start service instance
$ServiceInstance = Get-SPServiceInstance | Where-Object { $_.TypeName -eq "Managed Metadata Web Service" }
#Check the Service status
if ($ServiceInstance.Status -ne "Online")
{
Write-Host -ForegroundColor Yellow "Starting the Managed MetadataService Instance..."
Start-SPServiceInstance $ServiceInstance
}
Write-Host -ForegroundColor Green "Managed Metadata Service Application created successfully!"
}
catch {
Write-Host $_.Exception.Message -ForegroundColor Red
}
finally {
#Reset the Error Action to Default
$ErrorActionPreference = "Continue"
}
and here is the result of the above PowerShell script to create managed metadata service application:
You can use the optional parameters such as the URL for the content type hub from which the service application will consume content types.
Is line 10 correct?
Should not it mean:
$ContentTypeHub=”https://intranet.crescent.com/ctypehub”