The below script can be used to extract the list of all site collection, its title, URL, Template, Template ID from a specific web application:
$rootSite = Get-SPSite "link of specific web application"
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites)
{
foreach($sites in $site.RootWeb)
{
write-host $sites.url , $sites.Title , $sites.WebTemplate , $sites.WebTemplateId
$sites.url + "$" + $sites.Title + "$" + $sites.WebTemplate + "$" + $sites.WebTemplateId | out-file "G:\Scripts\Outputs\SPTemplates.csv" -Append
}
}
$web.Dispose()
$site.Dispose()