Posts Tagged 'list'

Here’s how you can create and delete views in a SharePoint list or library using PowerShell (Is there anything that can’t be done through a PowerShell script?)

The script below creates a view called “TestView”. It expects three command-line arguments: site collection URL, the name of the view to create, and the list GUID. The view that’s created is an exact replica of the “All Items” view (you can certainly modify the code as needed). Here’s how you would call this script from the command line:

Finally, how do you find out the GUID of your list? It’s fairly straightforward – you just need to access the SPList.ID property of your list. Here’s a simple script that will output the GUIDs of all lists in your site collection:

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).