I am creating a script to upload contact information to a sharepoint list. One of the columns (Categories) is a choice field with checkboxes for multiple selections. I need to figure out a way to add checks to this field if I have multiple Categories in my CSV. For example, two of the check boxes are vendor and project manager if a contact in my CSV has both i need the item in the sharepoint list to have both. Here is the code I have so far:
# Setup the correct modules for SharePoint Manipulation
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
$host.Runspace.ThreadOptions = "ReuseThread"
#Open SharePoint List
$SPServer="http://SPsite/itv2"
$SPAppList="/Lists/Test CSV Upload"
$spWeb = Get-SPWeb $SPServer
$spData = $spWeb.GetList($spWeb.ServerRelativeURL + $SPAppList)
$InvFile="C:\Scripts\ContactUpload.csv"
# Get Data from Inventory CSV File
$FileExists = (Test-Path $InvFile -PathType Leaf)
if ($FileExists) {
"Loading $InvFile for processing…"
$tblData = Import-CSV $InvFile
} else {
"$InvFile not found – stopping import!"
exit
}
# Loop through Applications add each one to SharePoint
"Uploading data to SharePoint…."
foreach ($row in $tblData)
{
"Adding entry for "+$row."GivenName".ToString()
$spItem = $spData.AddItem()
$spItem["First Name"] = $row."GivenName".ToString()
$spItem["Last Name"] = $row."Surname".ToString()
$spItem["Email Address"] = $row."Email1EmailAddress".ToString()
$spItem["Business Phone"] = $row."BusinessPhone".ToString()
$spItem["Mobile Phone"] = $row."MobilePhone".ToString()
$spItem["Categories"] = $row."Categories"
$spItem.Update()
}
"—————"
"Upload Complete"
$spWeb.Dispose()
$spWeb.Dispose()
I need to find a way to "concatenate" checks to the categories field, so that I am able to search the categories field for any of the checked boxes. So far everything I have done will add vendor,project manager to the column, but then I am not able to filter it by vendor and have the contact come up.