Friday 31 December 2010

Closing a popup dialog after running server side code

Problem: A base page allows a user to perform additional logic such as inserting a a new row into a list via the Dialog Framework.  The new row is a custom page that is shown thru the Dialog framework.  The custom page contains a web part that allows the user to fill in a form, perform custom logic and insert the record.  You now need the dialog page/popup to close automatically after the server side code is run.  The problem is you need to run the server side code before closing the window.

Initial Hypothesis:  I have been using jQuery with a hidden server control to set a value on the server side after my custom server side actions.  Then after the page reloads due to the postback, on the jQuery $document ready I check if the hidden value has been set and if it has I use the dialog framework to close the page.  A fair amount of work and round trips to solve my problem.

I saw a post on the msdn forums which is much simpler & better solution.  I implemented this and it is much easier and better than my hidden variable approach.

Resolution:
Place the code snippet in the server side code i.e. in the button click after you have performed your server side logic.

More Info:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/ba06d5e5-8c4c-4bca-95f8-65f40c1b11fa

Wednesday 29 December 2010

LINQ to SharePoint by Example

Problem: Simple examples to perform CRUD operations using LINQ to SharePoint. 
Resolution:
Read Operation/Select (Get a single row) & Update Operation/Update (Update a row), this code uses the default context constructor to retrieve the customer, you can use less code to achieve the same result.
Create Operation/Insert (Add a new row to a list)
Delete a customer list item.

Connected Web Part Series - Part 1

Problem: There is a lot of information relating to web parts however this series is aimed at connected web parts in SharePoint 2010.  This 1st post deals with creating a custom connection between 2 visual web parts (a provider & a consumer).

Overview:  Create a Interface to enable communication between the provider and the consumer web part.  Create Visual User controls to connect to each other. 
Tip: Web Parts are easier to connect than Visual Web Parts, so only use Visual web parts if there is a heavy visual requirement.

Steps:
Create a new Web Part (it will be the provider web part)
 Create an Interface (contract between the provider and consumer web parts)
 Implement the Interface in the Provider web part
Create the Consumer web part as shown below
Deploy the solution and activate the feature that contains the 2 web parts
In a browser add the 2 web parts to a page (Provider & Consumer) 
 Connect the 2 web parts as shown below

Friday 24 December 2010

Connected Web Part Series - Part 2

Title: Creating a web part that is both a consumer and a provider.

Problem: I needed a web part that receives data from a provider web part.  The same web part then passes data onto a consumer web part.  I.e.  WebPartGetUser (Provider), WebPartShowWeeks (Consumer & Provider) & WebPartShowProductsOrderedinWeek (consumer). 

Hypothesis:
WebPartGetUser - Retrieve the user and passes the user id to the web part WebPartShowWeeks.
WebPartShowWeeks  - Consumes the UserId and show weeks where the user placed an order.  A drop down list show all the weeks, when the week is selected, the week is passed to the WebPartShowProductsOrderedinWeek web part.  This show all the orders placed in a specific week.

Wednesday 15 December 2010

SharePoint 2010 boundries and thresholds

I attended a suguk.org event in London about a week ago.  John Timney did the 1st presentation session and asked a couple of questions on SharePoint limits.  I didn't know the answers, tried to think back to MOSS and what I'd seen previously.  The simplest question that I should know the answer to:

Qu: What is the maximum content database size supported by SharePoint 2010?
Ans: Microsoft supports Content databases up to 200GB in size.  In MOSS it was 100GB.  It is fairly common to see content databases considerably bigger than 100GB in MOSS that work.   The issue is how long does it take to perform operations on these content DB's such as backups moving content db's.  If you have a dedicated SAN, there is no reason not to go to much larger content databases however, they are not supported by MS.

More info on SharePoint's boundaries and thresholds from MS

Qu: What I/O speed does MS recommend for your SharePoint 2010 SQL database?
Ans:  I/O operations per second (IOPS).  The faster that SQL can handle request, results in faster return time and reduced que requests, so pretty important and a fairly common bottleneck.  This is often a reason why people choose not to virtualise SQL Server, it I/O intensive in SharePoint and really important to be fast.  Tip: Ensure VM's are thick provisioned for SQL Server. 

To determine you IOPS  use SQLIO Disk Subsystem Benchmark Tool (http://go.microsoft.com/fwlink/?LinkID=105586).

I guest the answer is as fast as possible but you can determine your IOPS requirement using the tool and you usage.  I go with ldf files on the fastest disk on the TempDB followed by ldf files for the content dbs on spinning disks.

Update 09/06/2011
Qu: Should I using seperate disks for mdf (data files) & ldf (transaction logs)?
Ans:  On small SQL server farms ensure that the transaction logs are stored on a different physical drive to the content databases as this will reduce contention and increate performance signigicantly.  Larger SQL instances like SANS have multiple disks so there is no need to seperate the files as this is already done by the nuber of disk readers.  You can also check the performance of a drive by watching the "disk seconds per read/write counters" which should be less than 20ms.  If the disk seconde per read/write is approachiing 20ms consider improving the disk speed or increasing the number of read points.
Update 22/08/2012 - Bigger architectures may use SSD/Flash memory as opposed to disks.  The IOPS are hugely improve as the is no disk search time.  http://technet.microsoft.com/en-us/library/cc298801.aspx#Section1_5a

Qu: What is the default SQL Server database growth setting sizes?
Ans: SQL Server 2008 will grow data files by 1MB and transaction logs by 10% increments.  I would start with an initial content database size of 100MB(adjust according to your anticipated demand) and autogrowth to be 50MB (adjust according to your system).  This general prinipal will result in the growth to the db's being infrequent so the associated performance hit is reduced, unused space being optimised as the percentage growth in the transaction log has huge incremental hit that are generally never reached after initial growth and less fragmented databases results in faster performance. 

More Info:
Summary of limits and thresholds
http://blah.winsmarts.com/2010-5-How_big_can_my_SharePoint_2010_installation_be.aspx
SQL Checklist for SharePoint 2013

Tuesday 14 December 2010

ULS Viewer

Problem:  The ULS log generated by SharePoint 2010 are difficult to read and review as the logging is store in flat text files.

Initial Hypothesis: ULS Viewer allows the administrator/developer to track, understand and solve issues on your SharePoint environment.  The ULS viewer is not a supported product my Microsoft however, it is alot easier to discover errors than using notepad and opening each ULS log.  Logs are located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS by default.

Resolution:
1.> Download the ULS Viewer
2.> Map a folder to the c drive on my UAT environment.
3.> Open the ULS Viewer.
4.> To view the logs as the are added, Click File > Open From > ULS, select the Logs location on your mapped drive.
5.> Add multiple WFE's log by using the File > Append From option.
6.> To view historic files, copy the log files from the server to your local machine and click File > Open From > File, select multiple ULS log files to see the server history.

How to use the ULS Viewer blogs:
Jie Li
Jeremy Taylor

Wednesday 8 December 2010

Uploading multiple files in a document library

Problem: In a SharePoint 2010 document library, the "Upload Multiple Document" option behaves differently in Internet Explorer (IE) in the User Interface (UI) on end user machines.  Either the "Drag and Drop" or the "multi tick tree view upload view" is shown in IE for multiple file uploads. 
Initial Hypothesis
1.> I originally thought Silverlight was responsible for the different displays, I remove Silverlight from the client machines and I still see the working drag and drop control.  Therefore the difference has nothing to do with Silverlight.  Additionally, this is not an IE version issue.
2.> Removing Silverlight and restarting the browser/machine has no effect, I still can use the drag and drop control. The ActiveX control that performs the upload must be responsible for the UI.  More info. 
3.> Only IE has the option to "Upload Multiple Document".   The "Upload Multiple Document" is not available in FireFox or Chrome.
4.> The Office ActiveX plug in is STSUPLD.DLL.  I found the file on my client machine located at  e:\Program Files(x86)\Microsoft Office\Office14\STSUPLD.DLL.  My version is obviously part of the Office 14/Office 2010 release. 
5.> Removing the  e:\Program Files(x86)\Microsoft Office\Office14\STSUPLD.DLL file and restarting IE results in the "Upload Multiple Document" option being disabled (greyed out).
6.> Replacing the STSUPLD.DLL with the Office 2007 STSUPLD in the Office14 or Office12 directory does not fix the issue it merely still greys out the "Upload Multiple Document" option.

Resolution:  The behaviour is part of the version of Office installed on the client machine.  The multi upload option is only available in IE if the client has the ActiveX control installed with Office.  I believe it comes down to the last office product installed so if you have Office 2010, you get the drag and drop UI however if you install SharePoint Designer 2007, you will see the tree view as you will be using the STSUPLD.dll from Office 2007.  Functionality is really out of your control as it comes down to the client machine setup.  You can do javascript to check the plug-in version and change default display if you need to.

Check your version by finding the STSUPLD.DLL (I think you can do it in IE also), the details of the 3 versions are shown below:
 
Office VersionDll VersionDll Size
Office 200311.0.5523.0?
Office 200712.0.4518.101422kb
Office 201014.0.4761.100078kb

Tip: The ability to use Windows Explorer to upload files to a SharePoint document libray relies on the Os being 32bit.  So on the x64 bit Windows Server, you can't upload files using Windows Explorer.


This control is currently disabled - Document library

Problem: Upload Multiple Documents is disabled with the message "This control is currently disabled.".  If the new documents and various other documents on the ribbon are disable and showing the same message.

Initial Hypothesis:  The Authentication provides have not been configured to Enable Client Integration.

Resolution: CA > Manage Web Applications > Select the WA > Authentication Providers > Select the zone > Enable Client Integration = Yes.

 

Tuesday 7 December 2010

Amending the Welcome Menu

Problem: Welcome Menu or Personal Actions Menu occasionaly refered to as the User Menu. SharePoint 2010 that displays the users name in the Welcome server control, this by default in the top right of the master page.  You can add new menu items or hide existing menu items.
Initial Hypothesis
  • The Welcome user control is located in the 14 hive at 14\TEMPLATE\CONTROLTEMPLATES

  • The user control is reference in master pages.
  • Take a copy of the welcome.ascx file as you will be working on the original or need to reference your new copy in your master page.
Resolution: Hide the menu option in the Welcome Menu.
Use the PermissionString property to dispay the menu option depending on your permissions.
Edit the Welcome.ascx file for each menu option element add the visible attribute and set it to false to hide the menus.
List of valid properties for the PermissionsString property
Alternatively set the MenuItemTemplate attrivute visibility to false, this will hide the menu option for everyone.
 
Resolution - Another option for changing the welcome control:
  • Remove the server control wssuc:Welcome from the master page or set it's visibility to hidden.
  • Then write a Replacement control and add it to the master page.

 Resolution:  Add a new menu item
  • Add a new element to the project that will be deployed as a feature

  • Add the following code to the element file

 

  •  New menu item (Open BBC) is add to the welcome menu.

 

More Info:
http://glorix.blogspot.com/2007/08/custom-action-locations-and-groupid.html
http://www.sharepointnutsandbolts.com/2007/07/using-customaction-to-modify-system.html
http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx

How to Hide Ribbon
http://blogs.msdn.com/b/zwsong/archive/2010/04/29/how-to-hide-ribbon-from-users-without-edit-page-privilege.aspx

Chris O'Briens Ribbon Customisation blog series
http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html

Sunday 5 December 2010

Sandboxed Solution with Full Trust Proxy

Problem: You deploy code as a sandbox solution however it fails as you need to go beyond the permissions a sandboxed solution can perform.  For example sandbox solution code cannot write to the ULS and security is restricted so you won't be able to use RunWithElevatedPrivileges.

Resolution: You can develop a full trust proxy that is deployed into the GAC, you also need to register the full trust with SharePoint.  Lastly, create the code for your sandboxed solution using the Full Trust Proxy code.  The full trust proxy performs the operations that are beyond what the sandbox solution code is allowed to perform.
Update 23 April 2011 - CKSDev is an extension tool for Visual Studio that has a SPI (template) to create a full trust proxy.  This will do all the plumbing of creating the full trust proxy and the deployment packaging.  So if you are wanting to add a Sandbox Solution Full Trust Proxy for Logging use the VS template provide and all you need to add is your logging code.

More Info:
http://blah.winsmarts.com/2009-12-SharePoint_2010_Sandboxed_Solutions__Full_Trust__Proxies.aspx
http://ranvijaysingh.blogspot.com/2010/06/full-trust-proxy-in-sharepoint-sandbox.html

Thursday 2 December 2010

Error occurred in deployment step Activate Features Failed to activate feature .. at scope

Problem: When deploying a soluction in VS 2010 I get the following error.

"VS Error: Error occurred in deployment step 'Activate Features': Failed to activate feature 'XX' (ID: xxxa2e8a-78d7-451c-aa85-3d28555e5555) at scope 'http://demo.dev'."
ULS contained the following error "Feature Activation: Threw an exception, attempting to roll back. Feature 'XX' (ID: 'xxxa2e8a-78d7-451c-aa85-3d28555e5555'). Exception: System.InvalidOperationException: Failed to activate feature 'XX' (ID:xxxa2e8a-78d7-451c-aa85-3d28555e5555) at scope 'http://demo.dev'. at Microsoft.SharePoint.SPFeature.HandleActivateError(SPFeature featError, Int32 iRetVal, Boolean fForce)"

Initial Hypothesis: Performing an IISreset did not resolve my issue, the suggestion to manual start the feature will activate the feature however it does not solve my deployment issue from VS. The feature is scoped at 'Site' level so activating the feature can be done at the site collection level.

Resolution: Removed the feature and solution using Powershell Rebooted Visual Studio development environment Open solution in Visual Studio 2010 and redeployed.  The cause is still not know however, rebooting and uninstalling the solution has fixed the issue.
More Info:
http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/ee35db1a-b83f-477e-ba6b-f59ac8522e34/

The parent content type specified by content type identifier ... does not exist

Problem: When I deploy a solution that automatically activates a feature I receive the following error "Error occurred in deployment step 'Activate Features': The parent content type specified by content type identifier 0x0120D520 does not exist.".
Initial Hypothesis: The feature being deployed relies on another feature being activated, in this case it is the 'Document Sets' site collection feature that is missing.
Resolution: Site Settings > Site Collection features > Document Sets (Activate)
More Info:
http://msdn.microsoft.com/en-us/library/aa543822.aspx

Cannot insert duplicate key row in object

Problem: Error occurred in deployment step 'Add Solution': Cannot insert duplicate key row in object 'dbo.Solutions' with unique index 'Solutions_BySiteAndSolutionId'.

Initial Hypothesis: Sandbox solution wsp deployment is causing the error. I delete and created a new site collection with an identical url.

Resolution: Using Visual Studio 2010 in the solution browser, select the project that is not deploying. In the properties window change the 'Site URL' property that tells Visual Studio the site to deploy your project code to. Change the 'Site Url' to something else save the change and then change the 'Site Url' property back to its original value.  Redeploy the project and it deploys correctly.  Thanks to Brian Farnhill.
Read More:
http://blog.brianfarnhill.com/2010/11/16/error-cannot-insert-duplicate-key-row-in-object-dbo-solutions/

Monday 29 November 2010

SPMetal Extender CodePlex project

I have release a project on codeplex, SPMetal Extender to be able to use additional field types.  Fields in lists can be extended using partial classes.  The project provides a Visual Studio plug-in vsix that generates Linq to sharePoint code for unsupport list fields such as publishing fields.  Additionally the vsix deploys a new template showing how to add 4 additionaly properties to SPMetal.  The Item template is guidance and needs to be adjusted by the developer after it is created.
SPMetal Extender VSIX extension installed
Add a new SPMetal Extended item to a SharePoint project
Generate code for addionnal list fields using Server Explorer using the VS IDE

SPMetal Extender is also published on Microsoft Visual Studio tools gallery 

Saturday 27 November 2010

Error adding webpart containing validation control

Problem: When adding a custom built webpart with asp validator controls to a page, the user will encounter the following error when attempting to save the changes "Error: This page contains content or formatting that is not valid.".
Initial Hypothesis:
This error only happens when the webpart control has validators and prevents the user being able to add the webpart to the page.

Resolution: Disable the validator controls when editing the page.
Add the following public method in the server control code ...
public void EnableValidators(bool enableVal)
{
this.validatorName.Enabled = enableVal;
}
In the Webpart's CreateChildControls() procedure only add the user control/validation when not in edit mode
if (SPContext.Current.FormContext.FormMode == SPControlMode.Edit || SPContext.Current.FormContext.FormMode == SPControlMode.New)
{
//validator.enabled = false
((UserControl1)_ctl).EnableValidators(false);
}
else
{
//validator.enabled = false
((UserControl1)_ctl).EnableValidators(true);
}
}
Add the EnableValidators method to the user control code behind:
 
The validators will then be disabled when adding the web part​ to the page / editing the page, but still work in presentation mode.

Thanks to Paul W

Change to session cookies for Claims Based Authentication

When you log into SharePoint using Claims Based Authentication, a cookie is written/persisted to ​disk (FedAuth) to persist your session, which prevents you having to be authenticated each time you open a new browser or re-boot.  So using a FedAuth cookie allows the browser to close and re-open windows as long as the FedAuth cookie has not expired.  For ADFS, FedAuth cookie expiry is by default set to expire 10 minute earlier than the SAML token.

You can change the cookie to be session based by running this PowerShell script:

$sts = Get-SPSecurityTokenServiceConfig
$sts.UseSessionCookies = $true
$sts.Update()
iisreset

You can revert back to a disk based cookie (default) by running this:

$sts.UseSessionCookies = $false
$sts.Update()
iisreset

Show cookies on a local machine for Internet Explorer

IE > Internet Options> General > Browser history "Settings" > Temporary Internet Files "View files".

Update 2016/03/10
Tip:  I wanted to examine a cookie to check the user being authenticate, and I opened the cookie using a base64 online decoder https://www.base64decode.org/




Update: 2016/11/23
IE Developer tool bar and Fiddler are great and easy to use and pretty feature rich but lately I have been using Chromes Developer toolbar press "Ctrl" + "Shift" + "i".



Linq to SharePoint - CRUD operations

Problem: Code to perform CRUD operations against a SharePoint list using Linq to SharePoint.
Resolution:
1) Read:
DataContext dc = new DataContext();
EntityList Customer = dc.GetList("Customers");
var CustomerItems = from Customers in Customer
select Customers;

Alternative approach


2) Insert:
DataContext dc = new DataContext();
CustomersItem Customer = new CustomersItem();
Customer.Title = "Title";
dc.Customers.InsertOnSubmit(Customer);
dc.SubmitChanges();

3) Update:
DataContext dc = new DataContext();
EntityList Customer = dc.GetList("Customers");
var CustomerItems = (from Customers in Customer
where Customers.Id == Convert.ToInt32(txtEditCustomerId.Text)
select Customers).Single();
CustomerItems.Title = CustomerItems.Title + txtCustomerTitle.Text;
dc.SubmitChanges();

4) Delete:
DataContext dc = new DataContext();
EntityList Customer = dc.GetList("Customers");
var CustomerItems = (from Customers in Customer
where Customers.Id == Convert.ToInt32(txtEditCustomerId.Text)
select Customers).Single();
dc.Customers.DeleteOnSubmit(CustomerItems);
dc.SubmitChanges();

Alternative approach 


Tip: If you are using read-only operation in your LINQ to SharePoint queries set ObjectTrackingEnabled to false to improve performance.
DataContext dc = new DataContext();
dc.ObjectTrackingEnabled = false;

Tip: Use the context on the generated proxy for performing LINQ to SharePoint queries.
More Info:
LINQ to SharePoint: CRUD operation on SharePoint 2010 list using SPLinq
LinqPad
LinqPad for SharePoint 2010

Wednesday 24 November 2010

Extending SPMetal

Problem: Using SPMetal retrieve a list and display the basic columns and the following 3 columns types:
  • Attachments;
  • Html Publishing field; and
  • Image Publishing field.
Resolution:
Extended partial class to retrieve attachments, a html publishing field and a publishing image.  The code link only does the read operation.
Extended partial class (advanced) to retrieve an attachment, a html publishing field, a publishing image and the hidden CreatedBy field.  You can use the parameters.xml when generating the SPMetal proxy to display additional hidden fields such as the CreatedBy field however, if the proxy has already been generated, it is easy to simple extend the partial class to get hidden fields.  This example also adds the code to insert and update the publishing html and the publishing image field columns.

More Info:
SPMetal only generates the proxy classes code against lists that site columns are available in SP2010 foundation.  So you also don't get Manage Metadata or any custom site columns you create.  You also don't get most of the built in columns with the exception of ID & Version using SPMetal.  However, by changing the parameters.xml file you can include them i.e. Modified, CreatedBy.  You can also use the extended partial class method to display the hidden built in site columns - I would use the parametes file and not the extended partial class coding for hidden fields(Field = Site Column).

Friday 19 November 2010

Deploying a Sandbox solution

Problem: I created several wsp packages, unfortunately 1 of the solution projects was marked as a Sandbox solution when the project was created in Visual Studio 2010.  The lookup lists are not deploying correctly in the sandbox solution because I deployed the solution at farm level.

Initial Hypothesis: I notice my lists had strange behaviour.  I check my deployment and 1 of the solutions had not been deployed.  When I deployed the wsp using Powershell (PS> Install-SPSolution ...) it did not error so I had presumed it had installed correctly.  Using PowerShell (PS) I could see the solution holding the list wasn't installed. PS> Get-Solution
Resolution: Retract the solution and remove it from the farm.  Deploy the solution to the Site Collection's solutions and enable the feature/s.  Powershell Commands:
PS> Add-SPUserSolution -LiteralPath D:\packages\.Lists.wsp -Site http://demo.dev

PS> Install-SPUserSolution –Identity Lists.wsp -Site http://demo.dev
PS> Enable-SPFeature –Identity Feature_GeneralLists –url http://demo.dev/

Tip: Update 10 Dec 2010 - If you remove a solution (this also applies to sandbox solutions) (including deactivating the associated features), if the feature deploys content types or site columns, you will need to do an IISreset if you want the content types and site columns removed from the Site Collection (alernatively restart the Web Application so the whole farm is not reset).

Post on deploying fasm wsp's.

Thursday 18 November 2010

Custom Claims Membership Provider

Problem: We have written a custom claims membership provider, it works in development however if fails in the UAT environment.  The Membership provider goes to an LDAP directory (IBM TAM).

Initial Hypothesis: After checking the configuration was correct, I looked at the logs that were informing me that the provider was not returning results.  We can't use wireshark on the UAT environment to verify the call is being made to the LDAP directory.  And the error message is a generic failure message.

Resolution: Use Telnet to check that the WFE/WebService/STS/SharePoint token service can speak to the LDAP directory.
cmd>Telnet 192.168.1.101 389

The Claims web service cannot contact the LDAP directory, most likely cause is the firewall or the windows firewall.  Add a rule to the firewall to allow traffic on port 389.

Wednesday 17 November 2010

Deploying packages into production using PowerShell

Problem: Developers build solutions and features for SharePoint 2010 using Visual Studio 2010 (VS), the farm wsp's need to be deployed in UAT, pre-production, production, CI potentially etc.  You don't have VS so you can use stsadm or Powershell.

Initial Hypothesis: This is a walk-thru on deploying your solutions and features in SharePoint 2010.  The main areas are:
  1. creating solution files (wsp's);
  2. moving them to the target environment;
  3. adding the various solutions and features at the appropriate level in your farm (features have 4 steps to get into production namely:
    • Add Solution,
    • Install Solution,
    • Install Feature and
    • Activate Feature.
Resolution:

1.> Create wsp's
1.1> Using VS2010, put the project into "Release" mode
1.2.> Next create the package using VS
2.> Copy the wsp located in the bin\Release directory of your VS solution to the farm where CA is hosted.
3.> Add solutions and activate features.
PS> Add-SPSolution D:\Packages\Demo.wsp
PS> Install-SPSolution –Identity Demo.wsp -GACDeployment
PS> Install-SPFeature demo_feature1 -force
PS> Enable-SPFeature –Identity demo_feature1 –url http://demo.dev/sites/demo
Tip: The feature scope requires different parameters.  For example if the feature above ( ) was scoped at Site (Site collection) level, the cmd would be: PS> Install-SPSolution –Identity Demo.wsp -GACDeployment –WebApplication http://demo.dev/
Scoped as web application level
PS>Install-SPSolution –Identity Demo-WepAppScope.wsp -GACDeployment –WebApplication http://demo.dev/sites/demo
Remove a web or site scoped solution
PS> Disable-SPFeature –Identity demo_feature1 –url http://demo.dev/sites/demo
PS> UnInstall-SPFeature demo_feature1 -force
PS> UnInstall-SPSolution –Identity Demo.wsp -GACDeployment
PS> Remove-SPSolution Demo.wsp
Cmd to add the SharePoint snapin, allowing the administration to manage SharePoint
PS> Add-PSSnapin Microsoft.SharePoint.PowerShell

Post on deploying Sandbox solutions.

Update: 27 Feb 2013.  The Install-SPFeature is only used for manual install i.e. not with wsp deployments but when you manually copy the feature files to each WFE.  You can keep the step as it has no negetive impact but it is not required.

Update: 20 May 2013.  This just bit me again.  I have an SP Timer Job scoped to WebApplication, by default when the solution/wsp is deployed, the feature receiver is activate automatically on ALL web applications (including MySites).  Change the Feature xml to include the attribute ActivateOnDefault="FALSE".

Read More:
http://sppowershell.com/2010/06/25/provisioning-sharepoint-2010-with-powershell/
http://msdn.microsoft.com/en-us/library/ms442691.aspx
http://stsadm.blogspot.com/2010/06/deploying-sharepoint-2010-solution.html
http://patrickboom.wordpress.com/2010/05/31/using-powershell-to-deploy-sharepoint-solutions-wsp-2/
http://dotnet.sys-con.com/node/1208275

Powershell - Running as a farm administrator using the SharePoint plug-in on Powershell

Problem: I need to run SharePoint Powershell commands in Production/UAT, I get remote access to the servers however the account is not the SharePoint farm account as the Famr account runns windows services and should not have remote access to the servers. 

Initial Hypothesis: Remote desktop into the WFE server, use the command prompt to launch Powershell using the farm account.  Lastly, add the SharePoint snapin for SharePoint 2010.
Update 6 Dec 2010 - Alternatively, hold down the shift key and right click the program you wish to run, you are given the "run as .." menu option.

Resolution:
1.> Remote desktop into the machine using a remote desktop access account i.e. demo\
2.> Open the cmd prompt and run the following cmd:
cmd > runas /user:demo\farm_admin c:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
3.> In the new Powershell windows add the PowerShell snapin
ps c:\windews\system32> Add-PSSnapin Microsoft.SharePoint.PowerShell
Read More:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/fcb77654-0f13-42e0-b181-6e52242fe9d6  Adding the SharePoint snapin to PowerShell.

Tuesday 16 November 2010

DateTime control default behaviour

Problem: The SharePoint date time control's default behaviour is to returns the current date and time when no date has been selected.
Initial Hypothesis: Validate the control to pre insert to check if it is selected, if no date time is choosen don't update the record.
Resolution:  The Property IsDateEmpty returns "false" if the date has been input.
Code:
if (!dtMyBirthday.IsDateEmpty)  { // ... User has delected their birthday date so insert into SQL table or list }
Read More:
http://karinebosch.wordpress.com/sharepoint-controls/datetimecontrol-control/

Monday 15 November 2010

Changing service account passwords - The Service is unavailable

Problem: Browsers return the following error "Service Unavailable  Http Error 503.  The Service is unavailable." on all SharePoint websites including central admin.
Initial Hypothesis: I changed my password yesterday causing the app polls to fail when logging in.  The domain account used on my development machine required a password change.  Starting the machine causes all the IIS web sites to display the error message "Service Unavailable".  I run various services and application polls using my domain account.  The services can no longer log on.  Application pool cannot be started after the reboot/iisreset.
Resolution:  Change the log on details for the application pools used by IIS that run using the domain account that's password was reset.  Also start the Windows services that run using the windows domain account.

Ensure the SharePoint services running

Friday 12 November 2010

Installing SharePoint using a dedicated Installation account

Problem: Best practice is to install SharePoint servers using a dedicated install account.  This account is not the farm account.  Once the installation is complete, the installation account should be disabled.  You need to install in the role of the admin account to install correctly. 

Note:  If your install and farm account are the same as is often the case, this post does not apply to you.

Initial Hypothesis:  It is only worth following this post if you are using at least 5 or more accounts for your farm install.  The idea is that the installation account is disabled after installation.

Resolution:  The farm account needs the 2 SQL Server security roles namely: dbcreator and securityadmin.  The farm account still needs local admin permission rights on each Web Front End (WFE) server.  The Installation account does not need any SQL Server permissions.

Using the codeplex AutoSPinstaller.  Launch the installer using a cmd prompt using the runs cmd to run in the farm domain admin priviledge.
cmd> runas /user:demo\farm_admin %windir%\system32\cmd.exe
cmd> D:\SP2010\Script>Launch.bat


You can also do the runas shotcut to change the account installing SharePoint.
Update 6 Dec 2010 - Hold down the shift key and right click the cmd prompt program menu, you are given the "run as .." menu option.

Update: 22 June 2011 - the current version of AutoSPInstaller is 2.5, additionallly the codeplex project is called AutoSPIntaller not SPAutoInstaller as previously named.

AutoSPInstaller - Step-by-step guide: http://blog.lekman.com/2010/11/automated-sharepoint-2010-installations.html