Monday, January 30, 2012

Powershell Delete Unused WF Column

This script works as a function – meaning that there are two parts to running it in the SharePoint 2010 Management Shell. First, you have to run the script shown below:
function Delete-WorkflowColumn ($webURL, $listName, $columnName)
{
    #Setup variables from the user input
    $web = Get-SPWeb $webURL
    $list = $web.Lists[$listName]
    $column = $list.Fields[$columnName]
   
    #Make sure the column is not hidden or read only
    $column.Hidden = $false
    $column.ReadOnlyField = $false
    $column.Update()

    #Delete column and dispose of the web object
    $list.Fields.Delete($column)
    write-host "Deleted column"
    $web.Dispose()
}


Once the function has been run, you can call it to actually remove a column with the following command:
Delete-WorkflowColumn -webURL http://portal -listName "Documents" -columnName "Approval Workflow"

The example above deletes the “Approval Workflow” column from all list views of a document library called “Documents” in the site http://portal/.

Whilst I have focused in this article on removing columns generated by unused workflows, you can use exactly the same script to remove columns from any list or document library.

Wednesday, January 25, 2012

Tuesday, January 24, 2012

Stsadm Commands

Export/Import

stsadm.exe -o export -url http://localhost/ -filename C:\Export.cab -includeusersecurity -versions 4 -overwrite
stsadm.exe -o import -url http://localhost/ -filename C:\Export.cab -includeusersecurity

Can export/import sub-sites with this method (i.e. http://portal/Communities/Employee)

http://technet.microsoft.com/en-us/library/cc288191(office.12).aspx

Backup/Restore

stsadm -o backup -url http://localhost/ -filename c:\helpdesk.bak
stsadm -o restore -url http://localhost/ -filename c:\helpdesk.bak -overwrite

http://technet.microsoft.com/en-us/library/cc263431(office.12).aspx

Wednesday, January 18, 2012

PowerShell Commands To List SharePoint Features

List all installed features on the farmIt’s really straight forward using the Get-SPFeature command to return all installed features. To provide a little more readability to the output it can be sorted as follows:
By feature display name alphabetically,

Get-SPFeature | Sort -Property DisplayName

By feature ID,

Get-SPFeature | Sort -Property Id

By feature display name alphabetically and grouped by scope,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id

And to write this to a file to allow for viewing in Notepad, Excel etc,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id > c:\AllInstalledFeatures.txt

List all activated site scoped featuresEspecially in the case of hidden features it’s sometimes necessary to track down if a feature is active on a site collection. Here’s a quick way of seeing which features are activated for an SPSite:

Get-SPFeature -Site http://sitecollectionurl | Sort DisplayName | FT DisplayName,Id

List all activated web scoped featuresAnd only slightly modified from the Get-Help Get-SPFeature -examples text, here is a command to list all web activated featres for a site collection:

Get-SPSite http://sitecollectionurl | Get-SPWeb -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | FT DisplayName,Id

From this site: Link to Site

Thursday, January 12, 2012

Uninstall ReportServer Feature in SP 2010

After upgrading to SharePoint 2010 I have these Site Content Types now in my site collection.  To get rid of them you have to uninstall the Report Server feature and re-install.

To do this in PowerShell:
Uninstall-SPFeature ReportServer -force
Install-SPFeature ReportServer

Go into Site Collection Features and activate Report Server Integration feature (and then deactivate if you don't need it).

Tuesday, January 10, 2012

Nintex URLs

Custom Start Page:
_layouts/NintexWorkflow/PHMIC_Custom/CustomStartWorkflow.aspx

Locate all Nintex flows in Site:
/NintexWorkflows/Forms/AllItems.aspx