I'm using the below PowerShell commands to get the last crawl duration. when the Crawl In-progress the 'Crawl Completed' field is empty, I the output as duration in negative values. Could you please help me to get the last crawl duration?
$SPContentSource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" |
Select Name , SuccessCount , CrawlStatus, LevelHighErrorCount, ErrorCount, DeleteCount, WarningCount, CrawlStarted, CrawlCompleted, @{label="CrawlDuration";expression={$_.CrawlCompleted - $_.CrawlStarted}} | ConvertTo-Html -Fragment