SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to update a metadata field when adding an item to document library. All the other columns are updating. The error is on this line and basically $taxfield is returning null.

$taxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$spItem.Fields["Region"]
$termSet = $termStore.GetTermSet($taxField.TermSetId) >> error on this line.

I am running this code with Admin and have full permission to the list.

= = = Error = = =

You cannot call a method on a null-valued expression. At C:\ps\AddFile.ps1:60 char:30 + $taxFieldState.SetFieldValue <<<< ($spItem, $termsST) + CategoryInfo : InvalidOperation: (SetFieldValue:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull

share|improve this question
try using the $list.Fields["Region"] instead of $spItem – David Lozzi Jun 22 '12 at 20:47
Did not help. $list=$web.Lists["Monthly Sales Report"] – Angie Heimerlake Jun 23 '12 at 0:28
What do you get when you use $taxField = $spItem.Fields["Region"]. Also try and paste some more of your code so we can understand what you are doing – Anders Rask Jun 27 '12 at 11:23
Do you use a localized version of SharePoint? The DisplayName of the field may be language-dependant! Can you get the field by its InternalName property (like $spItem.Fields.GetFieldByInternalName("InternalNameOfYourField")? – pholpar Apr 30 '15 at 17:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.