how to read a csv file and update a sharepoint column with multiple checkboxes

All,

Can someone help please! I am new to Power shell and have to write a script to insert data from an CSV file into sharepoint list.

The data in the csv file can be read easily - no issues. I have update all the SP column that have text from CSV.

The issue is when I try to insert a CSV column value to SP list column where the list is a multi select check-boxes.

(I inherited this project - pls don’t ask me why SP columns were designed this way).

For example in the csv file I have 2 columns that have favorite cities.

city1 city2

row1 Ottawa Toronto

row2 Montreal halifax

In the sharePoint column, I have FavouriteCity column:

[] Ottawa

[] Calgary

[] Toronto

[] Vancouver

 

How do I insert the value from csv file and force to select the corresponding item in sharepoint ?

I am looping through the csv file

foreach ($row in $dataFile)
{
$ListItemCreationInformation = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$NewListItem = $List.AddItem($ListItemCreationInformation)

$NewListItem[“FavouriteCity”] = $row.(“city1”)

}

How do I make Ottawa AND Toronto to be selected and saved?

 

Any guidance / example is greatly appreciated.

 

Thanks,

Guld_man

 

 

 

 

 

You cannot change UI objects without directly inte3racting with that UI object, via an API, or the default object Model. CSOM is what SP uses for the latter. Just do a search for ‘powershell csom sharepoint’ to get resources to review about dealing with that.

Example hits:

CSOM SharePoint PowerShell Reference and Example Codes https://social.technet.microsoft.com/wiki/contents/articles/29518.csom-sharepoint-powershell-reference-and-example-codes.aspx

See also:

SharePoint: A Complete Guide to Getting and Setting Fields using PowerShell https://social.technet.microsoft.com/wiki/contents/articles/20831.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-powershell.aspx

You say you are new to PS, the it is vital you get ramped up on it first, to decrease the confusion, misconceptions, errors, bad habits, bad code and the like…

See these resources.

https://www.reddit.com/r/PowerShell/comments/ar6cvt/powershell_in_depth_second_edition/egmlpom/?context=3
https://www.reddit.com/r/PowerShell/comments/afqmmw/i_want_to_help_my_husband_advance_his_powershell/ee3k6p6/?context=3

And this…

https://docs.microsoft.com/en-us/powershell
https://blogs.msmvps.com/richardsiddaway/2019/02/21/the-source-of-powershell-cmdlets

Best Practices

Windows PowerShell
https://docs.microsoft.com/en-us/powershell/developer/windows-powershell

PowerShell Standard Library: Build single module that works across Windows PowerShell and PowerShell Core
https://blogs.msdn.microsoft.com/powershell/2018/08/06/powershell-standard-library-build-single-module-that-works-across-windows-powershell-and-powershell-core

Windows PowerShell Best Practices
https://www.microsoftpressstore.com/store/windows-powershell-best-practices-9780735666498

PowerShellPracticeAndStyle
https://github.com/PoshCode/PowerShellPracticeAndStyle

PowerShell scripting best practices
https://martin77s.wordpress.com/2014/06/17/powershell-scripting-best-practices
https://blogs.technet.microsoft.com/heyscriptingguy/tag/best-practices

Powershell - Recommended coding style
https://lazywinadmin.com/2011/06/powershell-recommended-coding-style.html

What is the recommended coding style for PowerShell?
https://stackoverflow.com/questions/2025989/what-is-the-recommended-coding-style-for-powershell

PowerShell 4.0 Best Practices scripts
This is a place holder for all the scripts from my forthcoming Windows PowerShell 4.0 Best Practices book. Once the book releases, I will upload the 200 scripts to this location – which is currently referenced in my book. The idea is similiar to the one that I did for the Wi
https://gallery.technet.microsoft.com/scriptcenter/PowerShell-40-Best-d9e16039