Friday 24 May 2013

SharePoint 2010 Expiration Date Field Empty - Information Management Policy

I have been having this problem over the past few days while testing a workflow which is being triggered using a retention stage of the Information management policy.

I was testing on some documents which had been uploaded into a records library in my dev environment.

If you upload a document into a normal document library the document should have an expiration date set immediately.

To update the expiration dates you can run the Information management policy job which sets and updates the expiration date for all documents.

 
 

Once the expiration date is set on the document the next time the Expiration Policy timer job runs it will trigger the next retention stage for that document.

The Expiration policy job should always be ran (or scheduled to run) after the Information management policy job.



If you are using a Records Centre and your documents are stored in a records library there could be the possibility that the expiration date is blank.

I discovered this and first of all tried running the jobs I mentioned above, but to no avail.




After some digging I found that if your records are saved to the records library by the content organizer rules then on arrival in the records library the expiration date is set.

However if you upload a document directly in to a records library the expiration date is not set on upload, and in my environment it was still not set after running the Information management policy job multiple times.

I have not found a solution for records uploaded directly to the records library, but by uploading records to the drop off library and using the routing rules to move them to the correct records library you will ensure that the expiration date is set on all records!



Hope this saves anyone researching this particular problem some time!

Thanks for reading,

Matt

Tuesday 21 May 2013

Activating a SharePoint Feature on Multiple Sites or Site Collections using PowerShell

I have a very simple script that I have used so many times over the past two weeks I thought it is worthy of sharing.

I am currently working with a large number of site collections, and also a fair few custom solutions.

I have found time and again I need to either activate or even deactivate certain features on multiple site collections.

So the below script will allow you to do this in no time at all.

Hope this helps some others.

First step create a text file in the below format, you only need to define the URL for each Site collection or site.

SiteURL
http://sharepoint/sites/site1
http://sharepoint/sites/site2
http://sharepoint/sites/site3
http://sharepoint/sites/site4

You can list all features installed on your sites by using the following PowerShell: Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id

Then use the below PowerShell:
(You will need to update the feature IDs and the write host entries to match the features you wish to activate or deactivate.

 


$SiteList = Import-Csv Sites.txt

ForEach ($item in $SiteList)

{

            If ($item -ne $null)

            {

                Write-Host "Activated Branding Feature for: $($item.SiteURL)" -foregroundcolor cyan;
             
                Enable-SPFeature -id ed8d4f9d-c5a3-4358-a2ef-68be0163677f -URL "$($item.SiteURL)"

                Enable-SPFeature -id 36684dc7-fc72-4ec8-b056-111ead3f453a -URL "$($item.SiteURL)"               

                Write-Host "Activated Branding Features for: $($item.SiteURL)" -foregroundcolor green;
 
                Write-Host "Deactivating Workflow Feature for: $($item.SiteURL)" -foregroundcolor green;

                Disable-SPFeature -id cf724a88-9c1c-4f55-957a-d3f5be79a51e -URL "$($item.SiteURL)"
 
                Write-Host "Deactivated Workflow Feature for: $($item.SiteURL)" -foregroundcolor green;                     
 
            }

}

$web.update() 

$web.Dispose()