Add-PSSnapin -Name Microsoft.Sharepoint.Powershell #$taxonomySite = get-SPSite "http://SRVR1" #$web=Get-SPWeb "http://SRVR1/sites/SITE1" $MMDName = "Managed Metadata Service" write-host Connection made with site -$taxonomySite.Name $taxonomySession = Get-SPTaxonomySession -site $taxonomySite $termStore = $taxonomySession.TermStores[$MMDName] write-host Connection made with term -$termStore.Name $Group = $termStore.Groups["grp1"] write-host Connection made with group - $Group.Name $termset = $Group.termsets["ts1"] write-host Connection made with group -$termset.Name $term = $termset.terms["trm1"] write-host Connection made with group - $term.Name Write host $termset.ID Pause $name="Discipline" $newSiteColumn = $web.Fields.CreateNewField("TaxonomyFieldType", $name) $newSiteColumn.Group = "my Columns" write-host Connection made with $newSiteColumn # Update the properties of the new field. $newSiteColumn.SspId = $termStore.Id write-host Connection made with $newSiteColumn.SspId $newSiteColumn.TermSetId = $term.Id #write-host Connection made with $newSiteColumn.TermSetId #$newSiteColumn.AnchorId = [System.GUID]::empty #$newSiteColumn.AllowMultipleValues = $siteColumn.AllowMultipleValues $web.Fields.Add($newSiteColumn) #$newSiteColumn.Update() $web.Update() $web.Dispose() $taxonomySite.Dispose()
m trying to create a ne wtaxo.column through power shell.
but i am getting an error.
Connection made with 61bd90de-a9b0-4ca6-9fc8-076ea8c4edc9 Exception setting "TermSetId": "Specified argument was out of the range of valid values." At D:\ManagedMetadataCol_creation.ps1:41 char:23+ $newSiteColumn.TermSetId = $term.Id+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException+ FullyQualifiedErrorId : ExceptionWhenSetting
can someone pls point me why i am getting this .
help is appreciated!
Das