Improve Your Technology

Just another blog for techology

Listing all Sites and Webs having a List

When I was working for one of the customer I come across a requirement to update a list properties at all sites and sub-sites. Before updating list details I would like to know all the webs having the list. For this requirement I thought of writing small windows program to generate a CSV file with all the data. But later realized we have PowerShell to do all the things that we can do with a console application. Then I have written below script. After completion of writing, I realized the smartness of PowerShell. It reduced my turnaround time.

$date = Get-Date

$outFile = “.\ListDetails.csv”

$webappurl = “https://www.contoso.com”

$lists = @()

$webapp = Get-SPWebApplication $webappurl

$webapp.Sites | foreach-object{

$_.AllWebs | ForEach-Object{

$_.Lists | where-object {$_.Title -eq “MyUserList”} | foreach-object{

$list = New-Object System.Object

$list | Add-Member -MemberType NoteProperty -Name “Site Url” -Value $_.ParentWeb.Site.Url

$list | Add-Member -MemberType NoteProperty -Name “Web Url” -Value $_.ParentWeb.Url

$list | Add-Member -MemberType NoteProperty -Name “List Title” -Value $_.Title

$lists += $list

}

}

}

$lists | Export-Csv -NoTypeInformation -Path $outFile

The above script written for my requirement. You can create list object with all the properties that you want to capture. Once you created list object with required data you can export to csv file.

July 10, 2013 Posted by | Getting Lists, Power Shell, SharePoint 2010 | , , | Leave a comment

Content type level retention policy

Enabling Content type level retention policy

When I was working on a small POC I got a requirement to archive a specific content type data. There are more content typed associated to that list. So I thought of implementing a custom retention policy to set expiration if the item content type is in giving archive list. Then I realized in future if similar content type associated to another list or library again I have to enable the same retention policy for that list or library. I thought that it was not a good approach. Then I found solution with in SP 2010 its by default provides content type level retention policy. Below is the approach.

1. Go to your application, Site Actions -> Site Settings.

1

2. Click on “Site Content types”

3. Click on content type on which you want to apply retention policy. You will see below screen

2

4. Click on “Information management policy settings” link.

5. Check “Enable Retention” then you will see below screen.

3

6. Click on “Add a retention stage…” link to add new policy.

4

7. Create your policy. You can set retention policy based on default stage activate rules provided by SharePoint 2010 or you can refer custom retention policy.

Similaryly you can have retention policies at folder level.

December 28, 2012 Posted by | Content Type level retention policy, Retention Policies, SharePoint 2010, Technology | , | Leave a comment