In this recipe, we will use PowerShell to ensure that anonymous users can access the home page of our SharePoint site but cannot access the Site contents page.
Follow these steps to verify the anonymous access to content with PowerShell:
Create a new
WebClient
object. We are using theWebClient
object to make simple, unauthenticated web requests against our SharePoint site.$client = New-Object System.Net.WebClient
Use the
DownloadString
method to make a request for the home page of our site as follows:$client.DownloadString("http://sharepoint")
If we receive the HTML content for our page, our request was successful. However, if we receive an exception with a 401 or 403 HTTP response, anonymous access is most likely not available for that page.
Use the
DownloadString
method to make a request for the Site contents page on our site:$client.DownloadString("http://sharepoint/_layouts/viewlsts.aspx")
If the page is correctly blocked...