Categories
Server

Windows Server 2008 Disk Cleanup

SharePoint Central Admin has been prompting me, each time I’ve logged in, that one of my drives is running out of space. To be honest, there isn’t a lot that I can do – a small initial system drive and successive Windows updates have gradually eaten away at the free space – but I needed to free-up what I could.

The default install of Server 2008 doesn’t come with a disk clean-up option. You would normally have to install the “Desktop Experience” feature to get this option.

Handily, I found this post from Microsoft: Disk Cleanup option on drive’s general properties and cleanmgr.exe is not present in Windows Server 2008 or Windows Server 2008 R2 by default

Categories
Server

Downloading Solutions from Central Administration

This is a handy little PowerShell snippet that I needed to use today. There were two .WSP solutions installed within the SharePoint farm and I couldn’t locate the original source code.

$farm = Get-SPFarm
$solution = $farm.Solutions.Item("MySharePointSolution.wsp").SolutionFile
$solution.SaveAs("C:\MySharePointSolution.wsp")
Categories
Coding Server

Hiding SharePoint WebParts via Code

Another note to myself…

When wanting to programmatically hide a WebPart, don’t try to set it’s Visible property to False. This will cause you lots of trouble and create errrors. The correct method is to set its Hidden property to True.

if (items.Count == 0)
{
   this.Hidden = true;
   return;
}

 

Categories
Server

Set Up Groups for this Site

Note to self: Once a site has been created within SharePoint 2010, the ‘Set Up Groups for this Site’ admin page is hidden away – but you can set access it via /_layouts/permsetup.aspx.

Categories
Server

SharePoint & Item-Level Permissions within Document Libraries

I have a love/hate relationship with SharePoint. Often the things that should be really simple, just aren’t. Take the “Item-level Permissions” option for instance. Every list appears to have this option (available via List Settings > Advanced Settings) except for document libraries. I’m sure the SharePoint Development Team at Microsoft have a very good reason for this…

Step forth PowerShell!

$web = Get-SPWeb http://mysharepointsite
$list = $web.Lists[“A Document Library”]
$list.ReadSecurity = 2
$list.WriteSecurity = 2
$list.Update()
$web.Dispose()

The ReadSecurity value can be one of the following:

1 = “Read all items”
2 = “Read items that were created by the user”

The “Create and Edit access” option can also be set by specifiying a value for WriteSecurity.

1 = “Create and edit all items”
2 = “Create items and edit items that were created by the user”
4 = “None”

Categories
Server

Hiding Fields in SharePoint 2010

This is a useful peice of PowerShell script to hide specific fields from the Edit form. ShowInEditForm can also be amended to ShowInNewForm.

$assignment = Start-SPAssignment
$web = Get-SPWeb http://mysharepointserver -AssignmentCollection $assignment
$field = $web.Lists["Announcements"].Fields["Body"]
$field.ShowInEditForm = $False
$field.Update()
Stop-SPAssignment $assignment

Categories
Design & UI

SharePoint: University College Falmouth Intranet

These design solutions were created as part of the University’s move from a 10 year old, bespoke, Classic ASP driven Intranet (which I originally developed) to Microsoft SharePoint 2010. Their purpose was to act as a starting point for discussion among staff and students and to generate feedback.

Homepage

Sub Page

Categories
Server

SPListItem URLs

There seems to be no built-in function or property to quickly return the correct URL for a SharePoint list item. The obvious property, SPListItem.URL, always returns an invalid URL along the lines of http://sharepoint/Lists/MyList/155_.000. Not ideal.

To get around this and return a correctly formatted web address, you can use the following code:

item.Web.Url + "/" + item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?ID=" + item.ID

Categories
Server

Organising SharePoint Documents

I’ve been thinking about this for a while (how best to organise documents within a SharePoint website – whether to use document libraries or metadata) and have just stumbled across two blog posts, by Dustin Miller and Bil Simser, which seem to answers my queries.