Monday, December 4, 2017

SharePoint PowerShell Get-SPWeb Access Denied





I joined a company where they have a strict policy for not using service accounts for any administrative tasks. I was given an admin account for which DBA's provided access in the database. I thought I was set to use PowerShell when some commands(Get-SPsite, Merge-splog etc) worked. However I received the error below when I try to see the sub sites structure in a site collection.



To resolve, follow the steps below.


1. Go to Central Administration -> Manage Web Applications
2. Select the web application on which you are trying to run the powershell. This highlights the options like User policy, permissions policy etc
3. Select the User policy, provide your account details and select the "Full Control".


This gives your account the full control to all the content in that web application.

Thursday, November 9, 2017

Folders vs Metadata

Recently I worked with a company in which users heavily used folder structures in SharePoint libraries. They had no idea of Metadata concepts and its uses in SharePoint. They used the folder structure so religiously that many users had forgotten to create new document libraries itself. As a result all they had was one library with many many many folders. On the top of all this they had many folders where permissions inheritance was broken 😟.

I had to train those users about the SharePoint library best practices, uses of metadata in a document library etc by highlighting the difference between folders & using metadata in libraries


Category Folders Metadata
Familiarity Folders are very familiar to the users and easy to create & relate it to windows explorer, network drive. When the file is uploaded to a library with metadata columns, the user needs to tag or provide value for those columns which might need a little training. However, some columns can be defaulted if we plan the information architecture properly. For example, all the document libraries created in Sales site can have a metadata column "Department" defaulted to "Sales". Or the metadata column called "Document Type" in a "Training Documents" library could be defaulted to "Job Aids" etc.
Navigation Drill down & up to find the files. Very inconvenient. You can group the files based on a column value. Less clicks & easy to find files.
Search  Folder names will come up in the search, however there is no way you can refine/filter the results. For example, a folder named as 2017 comes up in the search but if the files inside it doesnt have the year 2017, it doesn't comes up in the search. Also, searching for a report that belongs to the current year "2017 financial statements", the file name should have all those words. If the SharePoint libraries are created using proper metadata columns and all the files inside it are tagged with the values, we will be able to refine the search results based the metadata column values. For example, when you search for a word "report", if you get 10000 results, you can refine the results by filtering on the department name, year, document type etc. given those are the metadata columns and added as refiners. 
Forced Grouping You will be forced to stick with the folder structure someone else has created.
Some likes to create the folders in the following structure.
Region->Year->Project Phase->Document Category.
Others might like: Year->Document Category->Region->Project Phase structure
No grouping. All those folders names can be metadata in a document library. Every document that gets uploaded will have metadata tag for region, year, project phase & Document category. Users will be able to filter based on the column values. The metadata columns can be created in a taxonomy term store to reused in content types across site collections or web applications.
URL Length  Since the folder name is part of the URL, deep folder structure is an issue as the URL character limit is 260. Although this has increased to 400 characters in recent version but the deep folder structure is still an issue Metadata columns are not part of the URL. So no issues in using as many columns as we want.
Name Change Folder name is a part of the URL. Changing the folder name changes the URL. Redistribute the link if you ever change the folder name.* Metadata is not a part of the URL. Nothing breaks if you tag the file as job aid instead of support document
Naming Convention Folder names depend on the person who created it. Changing them later will have the risk of breaking the link to the file or folder. You can control the taxonomy terms or metadata column values globally
* SharePoint 2016 version now has feature called "Durable Links" which doesn’t involve folder or file name in the URL. No broken links if you change the folder or file name

Wednesday, September 13, 2017

Modifying the Access Denied Page in SharePoint 2010

In my company, all the requests for SharePoint has to come through the Help Desk. We had disabled the "Request Access" link by going to "Site Permissions" and selecting "Manage Access Request" and unchecking the "Allow access request".


This was solution to just hide the "Request Access" link on access denied page. But my requirement was to add the help desk information with Phone number and email address for which I had to create a new "Access Denied" page.


Following are the steps to do the same.
  • Login to your WFE server, go to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
  • Create a folder called "CustomPages". [Note this is important because modifying the 14/15/16 hive is not recommended as the changes will be overridden when there is patching from Microsoft]
  • Copy the AccessDenied.aspx page from the step 1 to "CustomPages" folder and rename it to "CustomAccessDenied".
  • Open the CustomAccessDenied in notepad, Just above the <asp:HyperLink id="HLinkLoginAsAnother" ... add the line below
<p>To request access please contact the help desk xxx-xxx-xxxx or email xxx@xyz.com</p>



  • Save the file.
  • Now open the PowerShell Management Shell and type the command below
Get-SPCustomLayoutsPage –Identity "AccessDenied" -WebApplication "http://DEVWEBAPPLICATION



This shows the path for all the CustomLayoutPages like Access Denied, Error Page etc which will be blank as it will be default paths
  • To tell the SharePoint to use your new AccessDenied, run the following command
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/ExampleAccessDenied.aspx" -WebApplication


  • Execute Get-SPCutomLayoutsPage as below to see the effect

NOTE:
1. If you have multiple WFE, create the CustomPages folder and copy the file to other WFE servers as well
2. You don't have to run the command again in other WFE, but I have seen that you have to do an iisreset in other WFE(s) to tell the SharePoint to pick the new file.