Get Summary of Sharepoint Task Status via Powershell

You might need to run this as administrator if your task size exceeds the soft limit.


Add-PSSnapin Microsoft.SharePoint.PowerShell

$sharepointSite = "http://my.sharepoint.website";

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

$result = New-Object PSObject;
foreach($item in $spWeb.Lists["Tasks"].Items) {
$status = $item["Status"].ToString();
if($result.PSObject.Properties[$status]) {
$result.$($status) += 1;
}
else {
$result | add-member Noteproperty $status 1;
}
}
$result | ConvertTo-Json

it should produce something like the following:

{
    "Completed":  130,
    "Not Started":  7221,
    "In Progress":  1
}