Get details and creators of all Salesforce reports that reference a specified field

If you’re ever modifying a Salesforce field and you want to contact everyone who has created reports using the field, here’s how you do that using Powershell and the Force.com CLI (which you can also install via chocolatey):

set-location C:\wherever
force export
$reportFiles = get-childitem -Path .\src\reports\ -Recurse | sls “field_to_search_for"

# I’ve included some extra fields here, they might come in useful
$reportData = force query –format=json “select id, createdby.name, createdby.email, developername, name, foldername, isdeleted, lastrundate, lastvieweddate from report” | convertfrom-json
$matchingReports = $reportData | where { $reportFiles.Filename -eq $_.DeveloperName + “.report” }

$matchingReports | % { $_.createdby.name + ' created report “’ + $_.name +’"’ }
# send an email to these folks: $matchingReports.Createdby.email | select -Unique