Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

error while running below script. please help me

$
0
0

Hello Everyone, 

I am running below script and it worked in my dev farm. however it is not working in my PROD. I can see the term set group and, but the error is showing as null value at "term set group" parameter. 

$TermLabel = "TTest"

$TermGUID = "4654654564-21531451"

# Set your Term Store, Term Group, Term Set, and language

$mms = "Managed Metadata Service" #Managed Metatadata Service App name

$tg = "Metadata Test" #Term Group name

$tsName = "Deliverables" #Term Set name

$language = 1033 #This is a US English term

# Get the Site for context

$siteUrl = "https://csharepoint.test.ca/"



#Change nothing below this line

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea SilentlyContinue

$site = Get-SPSite $siteUrl

# Start a taxonomy session

$ts = Get-SPTaxonomySession -Site $site

#Get the Term Store

$termStore = $ts.TermStores[$mms]

#Get the Term Group

$termGroup = $termStore.Groups[$tg]

#Get the Term Set

$termset = $termGroup.TermSets[$tsName]

#Create a term with specific GUID within the term set

$termset.CreateTerm($TermLabel, $language, $TermGUID)

#Make it so

$termStore.CommitAll()

error: 

Cannot index into a null array.
At E:\CreateTermset-oldGUID.ps1:37 char:1
+ $termGroup = $termStore.Groups[$tg]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>