Embedding YouTube Videos in a SharePoint Page With The Page Viewer Web Part

There are a few different ways to present YouTube videos to users in a SharePoint 2010 portal. The trusty Silverlight Media Player web part (if you want to rip the media down locally) or a content editor linked to an external file are both viable options. But for the common page editor/content owner, those aren’t the most user friendly options available.

Enter the Page Viewer web part (aka the iFrame web part). How does this technological wonder better our lives? Watch and learn.
(more…)

SharePoint Saturday Virginia Beach 2012

SharePoint Saturday Virginia Beach 2012 is a wrap and it was a great time. Thanks to all who came out to attend the session with Dan Usher and I on Pitfalls of Migration to SharePoint 2010.

Organizations of all sizes are begging their technical departments to setup SharePoint 2010 so that they’re able to make use of some of the capabilities introduced within the SharePoint 2010 platform. While designing, implementing, configuring and deploying a system in and of itself has its own set of challenges, migrating into that shiny new SharePoint can be even more difficult.

In this session, Scott and Dan will share some of their experiences and lessons learned tips, tricks and pointers for ensuring that you’ve considered the various aspects of challenges that arise during a migration effort. Further, as a bonus they’ll share how to not fall prey to some of these pitfalls but rather be able to show that you’re a well rounded professional that’s thought things through before pressing the enter key.

SharePoint Saturday Richmond Decks

SharePoint Saturday Richmond is a wrap. Thank you to those who attended my sessions (and a special thanks to Dan Usher for allowing me to present with him). I apologize for the brevity of the Managed Metadata session, but there’s only so much disappointment I can dole out at once.

Trials and Tribulations of Managed Metadata

Pitfalls of Migrating to SharePoint 2010

Setting AutoCleanupDays With PowerShell in SharePoint 2010

The Problem

In it’s default configuration, SharePoint (2007 and 2010) will delete workflow associations after 60 days (e.g. the information found on the Workflow Status page). There are times when you may want to alter this functionality and retain the association for a longer period of time.

In SharePoint 2007, the recommendation from Microsoft (per TechNet), is to disable the Workflow Auto Cleanup timer job. The Workflow Auto Cleanup timer job is a web application scoped timer job. As such, disabling the job is often not the optimal solution; as disabling the job will ensure that cleanup is not occurring for all of the site collections within the web application for which the timer job was disabled.

The Solution

Thankfully, there is a property (SPWorkflowAssociation.AutoCleanupDays) that is exposed with the workflows associated with a given list/content type. And once again, PowerShell comes to the rescue, giving us the ability to manipulate the cleanup days at a more granular level. This ensures that we do not disable the timer job for an entire web application.

Presented as two functions, we can manipulate the workflow association settings for either the workflows associated with a list or the workflows associated with a content type attached to a list.

Set-SPListWorkflowAssocationCleanup

The following function allows us to set the AutoCleanupDays for all of the workflows associated with a given list.

Set-SPListWorkflowAssocationCleanup -WebUrl "http://intranet" -ListName "Shared Documents" -CleanupDays 365 -ReportOnly:$false
function Set-SPListWorkflowAssocationCleanup {
    param (
        [string] $WebUrl = $(Read-Host -prompt "Enter a Url"),
        [string] $ListName = $(Read-Host -prompt "Enter a List Name"),
        [int32] $CleanupDays = $(Read-Host -prompt "Enter the number of Cleanup Days"),
        [switch] $ReportOnly = $true
        )        

    $web = Get-SPWeb $WebUrl;
    if ($web -eq $null) {
        Write-Error -message "Error: Web Not Found" -category InvalidArgument
    } else {
        $list = $web.Lists[$ListName];
        if ($list -eq $null) {
            Write-Error -message "Error: List Not Found" -category InvalidArgument
        } else {
            [Microsoft.SharePoint.Workflow.SPWorkflowAssociation[]] $wfaMods = @();
            foreach ($wfa in $list.WorkflowAssociations) {
                $message = "Found Workflow Association for " + $wfa.Name + " with AutoCleanupDays set to " + $wfa.AutoCleanupDays
                Write-Verbose -message $message -verbose

                if ($ReportOnly -eq $false) {
                    $wfa.AutoCleanupDays = $CleanupDays;
                    $wfaMods = $wfaMods + $wfa;
                }
            }

            if ($ReportOnly -eq $false) {
                foreach ($wfa in $wfaMods) {
                    $message = "Setting AutoCleanupDays for " + $wfa.Name + " to " + $CleanupDays
                    Write-Verbose -message $message -verbose
                    $list.WorkflowAssociations.Update($wfa);
                }
            }
        }
    }
}

Set-SPListContentTypeWorkflowAssocationCleanup

The following function allows us to set the AutoCleanupDays for all of the workflows associated with content type for a given list.

Set-SPListContentTypeWorkflowAssocationCleanup -WebUrl "http://intranet" -ListName "Shared Documents" -ContentTypeName "Document Content Type" -CleanupDays 365 -ReportOnly:$false
function Set-SPListContentTypeWorkflowAssocationCleanup {
    param (
        [string] $WebUrl = $(Read-Host -prompt "Enter a Url"),
        [string] $ListName = $(Read-Host -prompt "Enter a List Name"),
        [string] $ContentTypeName = $(Read-Host -prompt "Enter a Content Type Name"),
        [int32] $CleanupDays = $(Read-Host -prompt "Enter the number of Cleanup Days"),
        [switch] $ReportOnly = $true
        )        

    $web = Get-SPWeb $WebUrl;
    if ($web -eq $null) {
        Write-Error -message "Error: Web Not Found" -category InvalidArgument
    } else {
        $list = $web.Lists[$ListName];
        if ($list -eq $null) {
            Write-Error -message "Error: List Not Found" -category InvalidArgument
        } else {
            $ct = $list.ContentTypes[$ContentTypeName];
            if ($ct -eq $null) {
                Write-Error -message "Error: Content Type Not Found" - category InvalidArgument
            } else {
                [Microsoft.SharePoint.Workflow.SPWorkflowAssociation[]] $wfaMods = @();
                foreach ($wfa in $ct.WorkflowAssociations) {
                    $message = "Found Workflow Association for " + $wfa.Name + " with AutoCleanupDays set to " + $wfa.AutoCleanupDays
                    Write-Verbose -message $message -verbose

                    if ($ReportOnly -eq $false) {
                        $wfa.AutoCleanupDays = $CleanupDays;
                        $wfaMods = $wfaMods + $wfa;
                    }
                }

                if ($ReportOnly -eq $false) {
                    foreach ($wfa in $wfaMods) {
                        $message = "Setting AutoCleanupDays for " + $wfa.Name + " to " + $CleanupDays
                        Write-Verbose -message $message -verbose
                        $ct.WorkflowAssociations.Update($wfa);
                    }
                }
            }
        }
    }
}

Conclusion

By manipulating the workflow associations for a list at the list/content type level the default configuration of a SharePoint farm can be retained (e.g. Workflow associations removed after 60 days) and in those cases where there is a business need, the workflow associations can be maintained for a longer period of time.

Reference

Performance Optimization WordPress Plugins by W3 EDGE