The mentioned below script explains how to get the System Account of a Web Application in the SharePoint using a PowerShell script.
  1. $farmWebAppService = (Get-SPFarm).Services | ? { $_.typename -eq "Microsoft SharePoint Foundation Web Application" }
  2. foreach($webApp in $farmWebAppService.WebApplications)
  3. {
  4. Write-Host "Web Application: " $webApp.Name
  5. $collection = @()
  6. foreach ($zonepol in $webApp.Policies)
  7. {
  8. if($zonepol.IsSystemUser -eq $true)
  9. {
  10. $collection += $zonepol;
  11. }
  12. }
  13. if($collection.Count -eq 0)
  14. {
  15. Write-Host "System Account (application pool account): " $webApp.ApplicationPool.DisplayName " - " $webApp.ApplicationPool.Username
  16. }
  17. else
  18. {
  19. foreach($item in $collection)
  20. {
  21. Write-Host "System Account (policy setting): " $item.DisplayName " - " $item.UserName
  22. }
  23. }
  24. }