Getting the field values of an Item in Sharepoint using Powershell

assuming you know the exact guid of the list and the item id, you can pull up the fields of a given item. This was originally derived from my work inspecting the Tasks and how to pull up the originating document that is associated with the Task/Workflow.


Add-PSSnapin Microsoft.SharePoint.PowerShell;

$sharepointSite = "http://sharepoint.url";

$spWeb = Get-SPWeb $sharepointSite;
$spSite = Get-SPSite $sharepointSite;

$list = $spWeb.Lists.GetList("{AC1FF751-626C-4873-B3CA-BDF24E206C4B}", $false);
$item = $list.GetItemById(2582);
foreach($entry in ($item.Fields | SELECT Title, StaticName)) {
$tmp = @{};
$tmp.Value = $item[$entry.StaticName];
$tmp.Name = $entry.Title;
$tmp.StaticName = $entry.StaticName;

$tmp | ConvertTo-Json
}