Here is the error:
The following exception was thrown when trying to enumerate the collection: “One or more field types are not installed properly. Go to the list settings page to delete these fields.”.
At C:\Users\me\AppData\Local\Temp\2\bca6fde0-a91f-427a-ad21-4794d47cebfc.ps1:24 char:17
+ $spList.GetItems <<<< ($spQuery)
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : ExceptionInGetEnumerator
Why?
Using PowerShell, I was trying to query a list. In my Where statement, I was calling a field by its display name, and not its INTERNAL name.
Bad code:
$web = Get-SPWeb "http://sharepointed.com/sites/taco"
$spList = $web.Lists["Taco History"]
$field = $spList.Fields["Taco Name"]
$value = "Grande Taco"
# Create Query based on field and value
$camlQuery =
'' +
$value +
'';
# SPQuery object
$spQuery = New-Object Microsoft.SharePoint.SPQuery
# Add query
$spQuery.Query = $camlQuery;
$spList.GetItems($spQuery)
This code will toss you the One or more field types are not installed properly….. error.
Using the friendly U2U Caml query tool, I rewrote my PowerShell Caml query. Doing this I noticed my field name issue. My fields display name is Taco Name but its internal name is Taco_x0020_Name. Doh!!!
Rewrite the PowerShell script and life is good!
Notice the new $field = $field.InternalName line in the script.
$web = Get-SPWeb "http://sharepointed.com/sites/taco"
$spList = $web.Lists["Taco History"]
$field = $spList.Fields["Taco Name"]
$field = $field.InternalName
$value = "Grande Taco"
# Create Query based on field and value
$camlQuery =
'' +
$value +
'';
# SPQuery object
$spQuery = New-Object Microsoft.SharePoint.SPQuery
# Add query
$spQuery.Query = $camlQuery;
$spList.GetItems($spQuery)