1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } $sourceWebURL = "http://sharepointsite" $sourceListName = "mylist" $spSourceWeb = Get-SPWeb $sourceWebURL $spSourceList = $spSourceWeb.Lists[$sourceListName] #$spSourceItems = $spSourceList.GetItems() #$spSourceItems = $spSourceList.GetItemById("1") $spSourceItems = $spSourceList.Items | where {$_['ID'] -eq 1} $spSourceItems | ForEach-Object { Write-Host $_['ID'] Write-Host $_['Title'] } |
You can either get all the items with GetItems() method currently commented out or you can filter items by some parameters. Filter applied in the script above is also equal to the GetItemById(“1”) method.
No comments:
Post a Comment