-
Notifications
You must be signed in to change notification settings - Fork 0
List and List Items
Takashi Shinohara edited this page Aug 31, 2021
·
1 revision
You can add a list item using the Add-KshListItem cmdlet.
Using a HashTable:
$value = @{ Title = 'My New Request'; Status = 'New' }
$list = Get-KshList -ListTitle 'Approval%20Requests'
Add-KshListItem -List $list -Value $valueOr using a PSCustomObject:
$value = New-Object -TypeName PSObject
$value | Add-Member -MemberType NoteProperty -Name Title -Value "My New Request"
$value | Add-Member -MemberType NoteProperty -Name Status -Value "New"
$list = Get-KshList -ListTitle 'Approval%20Requests'
Add-KshListItem -List $list -Value $valueYou can add multiple list items at once from a CSV file. This is useful for bulk inserts.
$csv = @"
Title,Status
My New Request 1,New
My New Request 2,New
My New Request 3,New
"@
$value = ConvertFrom-Csv $csv
$list = Get-KshList -ListTitle 'Approval%20Requests'
Add-KshListItem -List $list -Value $valueYou can retrieve list items using the Get-KshListItem cmdlet with the -All parameter. This will return all the items in the specified list.
$list = Get-KshList -ListTitle 'Approval%20Requests'
Get-KshListItem -List $list -AllYou can query list items using the Get-KshListItem cmdlet and a CAML query.
$list = Get-KshList -ListTitle 'Approval%20Requests'
Get-KshListItem -List $list -ViewXml '<View><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Approval for purchase</Value></Eq></Where></Query></View>'