How to remove a feature with PowerShell

Here are the PowerShell commands to remove a feature.

Step 1
Uninstall the feature.
Uninstall-SPSolution -identity “<WSP FileName>”
(For ex, Uninstall-SPSolution -identity “Deploy_Service_Requests_Lists.wsp”)

Step 2
Remove the solution.
Remove-SPSolution -identity “<WSP FileName>”
(For ex, Remove-SPSolution -identity “Deploy_Service_Requests_Lists.wsp”)

* Note pay attention to SPSoluion (farm solution) vs SPUserSolution (sandboxed solution). You need what kind of solution you deployed to know which command to use.

Here is the link to install a feature.

[tweetmeme only_single=”false”]
Advertisements

How to deploy a feature through PowerShell

Every time I go to deploy a feature from outside Visual Studio I forget the PowerShell commands.
I found the Corey Roth has a great blog entry about it and I end up going there.

So I decided to finally write up what I do.  After using stsadmin for so long it’s hard to make the adjustment to PowerShell.

Here is the first step to add a Farm Solution.
Add-SPSolution <File Path>\<WSP Filename>
(For ex, Add-SPSolution C:\Users\Administrator\Desktop\Deploy\Deploy_Service_Lists.wsp)

The next step is to install the solution.
Install-SPSolution –Identity <WSP Filename> p  –GACDeployment
(For ex, Install-SPSolution –Identity Deploy_Service_Requests_Lists.wsp  –GACDeployment)

*If you use Add-SPUserSolution it will be sandboxed solution.  Which I’ve done before at a client and I couldn’t find the solution because I used the wrong command.

** Workflows are a little different because they are not scoped at the farm level.  Here is the link to deploy a workflow.

[tweetmeme only_single=”false”]

How to deploy a workflow through PowerShell

Every time I go to deploy a workflow from outside Visual Studio I forget the PowerShell commands.

So I decided to finally write up what I do.   Here’s what I do.

Step 1 add the solution.
Add-SPSolution –LiteralPath <FILEPATH\WSP FileName> –Site <URL>
(For ex,
Add-SPSolution -LiteralPath C:\Users\Administrator\Desktop\Deploy\Service_Request_Workflow.wsp -Site
http://win-ate30fn6vk5 )

Step 2 install the solution.
Install-SPSolution –Identity <WSP FileName> –Site “<URL>”
(For ex, Install-SPSolution –Identity Service_Request_Workflow.wsp -Site “http://win-ate30fn6vk5&#8221; )

[tweetmeme only_single=”false”]

SharePoint generic handle web part error

If you have web part that has code behind to do something (like add data to a list) and it has an exception during processing you need a way to display that error.
Here is a generic method I use to display the error.
I put this in all my catches.  It will add a new literal control with the error.

        /// <summary>
       /// Clear all child controls and add an error message for display.
       /// </summary>
       /// <param name="ex"></param>
       private void HandleException(Exception ex)
       {
           this._error = true;
           this.Controls.Clear();
           this.Controls.Add(new LiteralControl(ex.Message));
       }
[tweetmeme only_single=”false”]

SharePoint error in Event Log

If you notice the following error in the event, there is a simple fix.

The Execute method of job definition Microsoft.Office.Server.Administration.ApplicationServerAdministrationServiceJob (ID c7f87cbb-e67d-44a2-9061-5321094aa81e) threw an exception. More information is included below.

 

Open Com Services and check the permissions on OSearch and IIS Admin Services.
The WPG group need to have permissions on Local Launch and Local Activate.

No back button

If your web app just can’t tolerate a user clicking the back button, you can tell the browser to not cache the page. Most of the time it will listen if you use this code, which covers all the bases:

Response.Expires = 60
Response.ExpiresAbsolute = DateAdd(DateInterval.Day, -1, Now())
Response.AddHeader(“pragma”, “no-cache”)
Response.AddHeader(“cache-control”, “private”)
Response.CacheControl = “no-cache”