Testing access to SharePoint pages

Let’s say you have a long list of SharePoint pages that need to be tested to verify that they’re permissioned correctly. One way to do it is to take a non-privileged account (end user) and attempt to connect to each of the URLs. If the page is locked down, you’ll get a page titled “Access denied”; otherwise, the page will load normally.

I recently responded to a thread on SharePoint TechNet about a similar issue and ended up writing a PowerShell script to address it.

The script below will read a text file containing a list of URLs (make sure to modify the source file path with your own path), and then call a function for each URL. This function will open a new instance of IE, navigate to the URL, wait for the page to load, and then grab the title of the page. If the user doesn’t have access to the page, the page title will contain “Access denied”; otherwise, the page title will be returned. Run this script under the credentials of one of your end users. If you’re trying to open individual documents (Word, Excel, etc.), you may need to modify the script so that it launches correct application (and closes it when done).