Prerequisite
SharePoint custom list (say continents) with some records as below:
Open the powershell ISE with run as administrator and run the below code:
- cls
- add - pssnapin microsoft.sharepoint.powershell
- $URL = "http://moss13:1111/"
- $ListName = "Continents"
- $SPWeb = Get - SPWeb $URL
- $SPList = $SPWeb.Lists[$ListName]
- $SPListItems = $SPList.Items | Where {
- $_['ID'] - ge 1
- }
- Write - Host("|{0,3}|{1,15}|{2,12}|{3,10}|" - f 'ID', 'Title', 'Area',
- 'Population') - ForegroundColor yellow
- Write - Host("________________________________________________")
- $Items = $SPListItems | ForEach - Object {
- Write - Host("|{0,3}|{1,15}|{2,12}|{3,10}|" - f $_['ID'], $_['Title'],
- $_['Area'], $_['Population']) - ForegroundColor yellow
- }
- Write - Host("________________________________________________")
Output will be as below-