Monday, May 30, 2011

Using PowerShell to Remove the "Use a Meeting Workspace" Option from SharePoint Calendars

When creating a calendar item (or updating) this is the dialog you get, with the Use a Meeting Workspace highlighted.

meetingWorkspace

From SharePoint Blues I discovered that if you set the calendar list field to hidden then this option would no longer display. Taking this concept, I created a PowerShell script to set this to hidden on a one off basis.

The script is:

# Script to remove Use a Meeting Workspace from a specific calendar

function RemoveWorkspaceLink ([String]$siteUrl, [String]$calendarName)
{
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
if ($site -eq $null)
{
return
}

$web = $site.OpenWeb()
$list = $web.Lists[$calendarName]
if ($list -eq $null)
{
"Invalid list name " + $calendarName
}
else
{
$field = $list.Fields[[Microsoft.SharePoint.SPBuiltInFieldId]::WorkspaceLink]
$field.Hidden = $false
$field.Update()
"Updated " + $calendarName + " on " + $siteUrl
}

# Dispose of the SharePoint objects
if ($web) {$web.Dispose()}
if ($site) {$site.Dispose()}
}

RemoveWorkspaceLink "http://myserver/sites/site1" "Calendar1"
RemoveWorkspaceLink "http://myserver/sites/site2" "Calendar2"

I’ve written this as a function so that you can update multiple calendars at the time. If you saved this as a .ps1 file and then run it, the 2 calendars referenced at the bottom would be updated. Alternatively you could . source the file and use the function interactively, or just hard code the $siteUrl and $calendarName variables each time you run it.

The option is removed immediately you have run the script with no iisreset or application pool recycle required.

So with the script is run this is what you see with the Meeting Workspace option removed:

meetingWorkspaceAfter

This works well for hiding it on individual calendar lists, but doesn’t affect any other existing calendars or ones created afterwards.

1 comment:

salamandersoft said...

This post has been stolen from my blog at http://blog.salamandersoft.co.uk/index.php/2011/03/using-powershell-to-remove-the-use-a-meeting-workspace-option-from-sharepoint-calendars/.

Please remove it from your blog.

Richard