Powershell script to change Sharepoint Information Policy for large document libraries (over 1 million docs)

Ran into an issue on a SP2010 farm that had over a million documents in a document library with a hundred thousand folders. Yes, lots of data, but not a bad practice in this case as it was tied to another system that relied on the folders. In any case, I was unable to change information Policy on document library with many thousand folders due to SharePoint’s UI which creates a tree view of folders on the page to change the Information Policy. Not the best design. So as my browser crashed waiting for 100,000 folders to load, we came up with a Powershell script to accomplish this. This script will create an Information Policy to delete all documents inside the document library that are older than 180 days. It is applied to the content type, but is scoped to the document library itself. Other libraries on the site are [...]