Get All Master Pages Applied to All sites in a SharePoint 2013

Below are the Powershell commands to get Master Pages applied to all the sites and sub site in a SharePoint Site Collection 2013.
  1. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue    
  2. #Get All site collections    
  3. $SiteCollections = Get-SPWebApplication | Get-SPSite -Limit All    
  4. #Loop through all site collections    
  5. foreach($Site in $SiteCollections)    
  6. {    
  7.       #Loop throuh all Sub Sites    
  8.       foreach($Web in $Site.AllWebs)    
  9.       {    
  10.            $MasterPage = $Web.GetFile($Web.MasterUrl);      
  11.            $MasterPage.Name  +" : " +$Web.Url      
  12.        }    
  13. }