PowerShell Remoting: Access Denied

Problem :

Getting access denied error when try to access $site.RootWeb.Lists over powershell remoting. User gets this error even if user has sufficient privileges to access the list.


Run following command for the account which is used to authenticate over PS remoting to get it running:

$w = Get-SPWebApplication -Identity http://portal

Reference Link here.

SharePoint Debugging : Determine which worker process to attach while debugging

Most of the times, during SharePoint debugging,we see that while trying to attach to process “w3wp”, many process with same name are listed.

How to determine which process we need to attach to? As the dialog box does not contain Application Pool details. Follow the steps given below to easily identify the correct worker process.

  1. Open the Command Prompt with Administrative Privilege
  2. Change the directory to c:\Windows\System\Inetsrv
  3. run “appcmd list wp“. It would list all the worker processed with ID and application pool information:


4. Find out process ID associated to the web application pool you want to debug.

5. Go back to Visual Studio “Attach to Process” dialog box and associate to correct process with ID we got in Step # 4.

Happy Debugging!!!!

Videos in Sharepoint

​Playing videos in sharepoint is bit tricky. Specially when you want to play videos with certain start and stop conditions as well as on all devices and on all browsers!


Requirement was as follows:

Dynamic poster image should be displayed and on clicking on image, dynamic video should play and after playback completes, again poster image should be displayed.

Should Work on: IE8,IE9+,Chrome,FireFox,Safari(For Mac & Windows)

Devices: Both PC and Mobile devices

Attached is the excel which contains various approach taken and problems with implmenting approach on various devices.



YouTube videos were embedded into code with help of YouTubePlayer API.


Following is sample code which can be tested in CEWP in sharepoint :

<script type=”text/javascript”>

function onYouTubePlayerAPIReady() {

var player = new YT.Player(‘divStartPlayer’, {

height: ‘555’,

width: ‘1000px’,

videoId: ‘hsfUNRRu0VY’,

events: {

‘onReady’: onPlayerReady,

‘onStateChange’: onPlayerStateChange




function onPlayerReady(event) {

if (!(navigator.userAgent.indexOf(‘iPad;’) > 0))





//Function to be called after video playback is completed

function onPlayerStateChange(event) {

if(event.data === 0) {





<div id=”divStartPlayer” ></div>


1) videoId​ is the ID of YouTube video

For Eg. YouTube video link looks like this


here, hsfUNRRu0VY is the ID of video

2) Note the code navigator.userAgent.indexOf(‘iPad;’) > 0 in onPlayerReady

function. Reason for placing such condition is that iOS does not support auto

playback of videos. (Check below link for reference)

iOS Auto-Playback disabled

So, if code contains method for playing videos, video will not load at all in iOS devices.​



sharepoint column default value settings not applied via content type


Created Document library and associated custom content type with a site column containing default value. Say a numeric field with default value 1.

But when i upload document and select my custom content type, default value does not appear and is always blank.

Reason and solution:

Thanks to SWEE CHING’s article, that i found the solution. Reason was that my custom content type was not set as default content type. If you want your default values to appead pre-selected, you have to set your custom content type as default.

Hope it will help someone!

Content Organizer execution order

Content Organizer is used to organize your content automatically, based on custom-defined rules. However, these rules add new entity to the hierarchy of events that can be executed for the List items, and this execution order is not well documented. It’s important to understand the sequence to process documents accordingly.
For example, when the user uploads his CV to the library you want to add watermark by Workflow, update .docx metadata with event receiver and round document to “unprocessed” folder using content organizer. We have “DropOff Library” with WorkFlow, EventReceiver attached and with Content Rules. The default execution sequence will be the following:
  1. WorkFlow
  2. Event-Receiver
  3. Content Organizer Routing Rules
PS: Take into account that WF/EventReceiver sequence can be changed programmaticaly, using Sequence property of SPList.EventReceivers, but when you reconfigure Workflow it always gets the first order in execution
PPS: Content Organizer Routing Rules impersonates the Application Pool account, thus in might perform actions under “System Account” and your destination folder’s WorkFlow will not start.

Stringbuilder object returning result while using Append function


For appending content to stringbuilder object we use Append() as

$sb = New-Object -TypeName “System.Text.StringBuilder”;
 $sb.Append(“This is a demo”);
expected the result is
This is a demo
However the result is
                  Capacity                MaxCapacity                    Length
                  ——–                ———–                    ——
                        16                 2147483647                         11
This is a demo
Several of the methods on StringBuilder like Append IIRC, return the StringBuilder so you can call more StringBuilder methods. However the way PowerShell works is that it outputs all results (return values in the case of .NET method calls).
In this case, cast the result to [void] to ignore the return value e.g.:
[void]$sb.Append(“This is a demo”)