I was looking for a script to export all unique permissions/broken permissions for sites, lists or document libraries and Pages items.From a quick Google search, I stumbled upon SharePoint 2010: Export All Unique Permissions from Site Collection using PowerShell. The script would have worked on SharePoint 2013 given it was run directly from the SharePoint server using Server Side Code.
I was site collection administrator without access to any SharePoint Servers. The only way was to use CSOM from PowerShell since I was not allowed to run any .exe/consoles files due to company policies on Live environment. The solution would work on both SharePoint 2013 On Premises and SharePoint Online.
The script can be downloaded from tech net gallery.
I amended the PowerShell code to the following. I have used script Load-CSOMProperties.ps1 from blog post Loading Specific Values Using Lambda Expressions and the SharePoint CSOM API with Windows PowerShell to help with querying object properties like Lambda expressions in C#.