Sunday, February 16, 2014

Basic PowerShell for SharePoint and the Equivalent STSADM used in Earlier Version

This is a simple list down of basic PowerShell commands used in command line deployments in SharePoint. [SP 2010 and 2013]  &
The equivalent STSADM commands used in SharePoint 2007 ... back in the day ;)


1. Adding a new WSP to farm solution

SP 2010/2013 PowerShell
 Add-SPSolution -LiteralPath "C:\FolderName\Solution.wsp"
SP 2007 
Stsadm
 stsadm -o addsolution -filename "Solution.wsp"
[Assuming command runs from the correct folder location]


2. Deploy WSP 

SP 2010/2013 PowerShell
 Install-SPSolution -Identity "Solution.wsp-WebApplication "http://WebSiteUrl" -CASPolicies -GACDeployment -Local -Force

AllWebApplications vs WebApplication - All allows the wsp to be deployed in all SP web applocations. WebApplication - allows the wsp to be deployed to a target web app
CASPolicies - Allows Code Access Security Policies to be deployed [optional]
GACDeployment - Allows DLL installation in the global assembly cache [optional]
Force [optional]
Local - Deploys only in the current server [optional]
SP 2007 
Stsadm
stsadm -o deploysolution -name "SolutionName" -url "Site URL" -immediate -allowgacdeployment -allowcaspolicies -force

instead of -url, you can use -allcontenturls 
instead of -immediate, you can use -time "time to deploy"

GACDeployment - Allows DLL installation in the global assembly cache [optional]


3. Activate feature

SP 2010/2013 PowerShell
 Enable-SPFeature –identity "FeatureName" -URL http://WebSiteUrl
SP 2007 
Stsadm
 stsadm -o activatefeature -id feature_ID -url http://WebSiteUrl -force
[Instead of -Id, you can use -filename or -name with appropriate values]



4. De-activate feature

SP 2010/2013 PowerShell
 Disable-SPFeature –identity "FeatureName" -URL http://WebSiteUrl
SP 2007 
Stsadm
stsadm -o deactivatefeature -id feature_ID -url http://WebSiteUrl
[Instead of -Id, you can use -filename or -name with appropriate values]



5. Retract WSP 

SP 2010/2013 PowerShell
Uninstall-SPSolution -Identity "Solution.wsp" -WebApplication http://WebSiteUrl
SP 2007 
Stsadm
stsadm -o retractsolution -name "Solution.wsp" -url http://WebSiteUrl -immediate 
[Instead of -immediate, you can use -time "TimeToRun"]



6. Remove WSP from SharePoint farm

SP 2010/2013 PowerShell
Remove-SPSolution -Identity "Solution.wsp"
SP 2007 
Stsadm
stsadm -o deletesolution -name "Solution.wsp"

Saturday, February 15, 2014

This version of Visual Studio does not have the following project types installed or does not support them

You might come across instances where you get the below message when opening SharePoint solutions in Visual Studio 2012.

"This version of Visual Studio does not have the following project types installed or does not support them"



1) The immediate remedy that pops into mind is to update the Visual Studio 2012 version.

The latest update for Visual Studio 2012, as of now is Update 4 (Released: November 13, 2013). Could get it from the link:  Visual Studio 2012 Update


2) Once that's done, you might get the following message on project load.

"An error occurred while trying to load some required components. Please ensure that prerequisite components are installed"
  • Microsoft Web Developer Tools
  • Microsoft Exchange Web Services

Possibilities are that either
  You don't have the "Microsoft Office Developer Tools for Visual Studio 2012" OR
  The installed tool is not complete.

Solution:
  • If the tool is already installed, uninstall through Control panel,
  • Download  Web Platform Installer   
  • Use the Web Platform Installer to install the tool.



Sunday, January 19, 2014

Join two tables in Update statement [T-SQL]

Two tables can be easily joined during an update, similar to a join used in a select statement. This comes in handy specially when one table needs to be updated based on a condition in another table. Below is one such example.

UPDATE C

SET C.permanentAddress='#000, Marine Drive, Galle, Sri Lanka'

FROM Customer AS C INNER JOIN users AS U

ON U.userId = C.customerId

WHERE U.loginName LIKE('%ashaamil%')


That's pretty much about it !

Saturday, January 18, 2014

SharePoint Web Parts Maintenance Page

SharePoint web part maintenance pages allows to manage (reset, delete) the web parts embedded into a particular page. It's useful in situations where its required to remove any web parts from a page which has caused a page crash.

For an instance if the page urls is:
http://localhost:1000/SitePages/Home.aspx

you can get the maintenance page by typing in "?contents=1" at the end of the URL string. Below is a sample:

http://localhost:1000/SitePages/Home.aspx?contents=1

This works the same in  SharePoint 2007, 2010 and 2013

Saturday, November 23, 2013

SharePoint Debug - Attach to Worker Process

Each SharePoint web application is run under a dedicated worker processes. Specially when it comes to DEV environments, when debugging a solution it's best to attach the code only to the target worker process. This avoids the hassle among the DEV team :) . It's pretty simple  to find the worker process related to the target web application. Follow these simple steps.


1) Start Command prompt with Administrator privileges
2) Navigate to C:\Windows\System32\inetsrv directory
3) Type in appcmd list wp


You get the list of  worker processes along with the web application which is running on it. Now in the Visual Studio IDE go to debugger and attach your code by selecting the appropriate worker process. Under the set of w3wp exe's you can pinpoint the exact one.


Saturday, October 26, 2013

Get-SPWebApplication is not recognised as the name of the cmdlet

When you try to execute SharePoint specific commands through PowerShell, might come across a message

"Get-SPWebApplication is not recognized as the name of the cmdlet ......"

The SP specific commands are not being recognized in PowerShell at this point. Adding a snap in would do the trick. Type the below command in your PowerShell  window.

Add-PSSnapin Microsoft.Sharepoint.Powershell

That's it. Provided that the rights in DB are there, you should be able to execute SharePoint based commands now.

Wednesday, September 25, 2013

When creating a Folder in Library - The server was unable to save the form at this time. Please try again [SP 2013]

In SharePoint server 2013 I tried to create a folder in side a document library and got this message.
"The server was unable to save the form at this time. Please try again".



 Was quite surprised at the beginning, but I kept getting this message over and over again. It seems like this is happening cause of a memory issue. At the time, the machine had only 8GB of RAM, which really should reach up to 16 GB of RAM for better performance.

Certain workarounds suggested that you restart the "SharePointSearch Host Controller Service" as a temporary solution to  free up some memory space. But it didn't do any good in my case.

Some were pointing out that the issue may have happened due to any add-on's installed in IE, But I didn't have any special add-on's in IE. Tried out the same using Chrome just to make sure I'm not missing anything. But still had no luck.

As a last resort did the famous iisreset assuming that anything held up will be released or refreshed. Nope, that didn't work either.

After some digging, I realized that Anonymous access to the site was disabled in IIS. Tried enabling it which was then followed by an iisreset and  ... Voila !! ... The Folder gets created !!   :)


So you have to Enable anonymous access at site level in IIS just to add folders to document libraries in SP2013 ??


....This somehow smells to me like a tiny