If you maintain big site collection in Sharepoint Online it will be useful to know what master pages are used in sub sites. The following script recursively iterates through all sub sites in specific site collection and prints master pages. Also it prints whether or not site master page and custom master page are inherited from the parent web:
Script uses CSOM v.16.1.6420.1200, but you may use other versions of course – download it and save in the script folder (you may need to change path from where assemblies are loaded – lines 8-9). Also it uses helper utility function Load-CSOMProperties (credits go to Gary Lapointe) which is analogue of ClientContext.Load function in C# which allows to specify which properties should be loaded via lambda expressions (in PowerShell there are no lambdas, so we have to use helper function). Script itself is quite simple – it recursively iterates through all sub sites and prints master pages (lines 144-160). Hope it will help someone.