jueves, 1 de septiembre de 2016

Set retention period for Usage definitions


Here's a sample script that will set the retention period to three days:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Set-SPUsageDefinition -Identity "Sandboxed Requests" -DaysRetained 3
Set-SPUsageDefinition -Identity "Content Import Usage" -DaysRetained 3
Set-SPUsageDefinition -Identity "Workflow" -DaysRetained 3
Set-SPUsageDefinition -Identity "Clickthrough Usage" -DaysRetained 3
Set-SPUsageDefinition -Identity "Content Export Usage" -DaysRetained 3
Set-SPUsageDefinition -Identity "Page Requests" -DaysRetained 3
Set-SPUsageDefinition -Identity "Feature Use" -DaysRetained 3
Set-SPUsageDefinition -Identity "Search Query Usage" -DaysRetained 3
Set-SPUsageDefinition -Identity "Site Inventory Usage" -DaysRetained 3
Set-SPUsageDefinition -Identity "Sandboxed Requests Monitored Data" -DaysRetained 3
Set-SPUsageDefinition -Identity "Timer Jobs" -DaysRetained 3
Set-SPUsageDefinition -Identity "Rating Usage" -DaysRetained 3

When a file can't be check-out / check-in or deleted because is locked from someone

Hello!

This is the time, when you can do magic via PowerShell..!

The PS script to unlock your file is this one:

$web = get-spweb "SITE URL"
$list = $web.Lists["LIST NAME "]
$item = $list.Items.GetItemById(DOCUMENT ID)
$item.File.ReleaseLock($item.File.LockId)
$web.Dispose()

ie:
$web = get-spweb "https://abcde.com/team/IT/SharePoint/"
$list = $web.Lists["Documents"]
$item = $list.Items.GetItemById(225)
$item.File.ReleaseLock($item.File.LockId)
$web.Dispose()

There are different ways to find the DOC ID, however the easy way is adding in your VIEW (list/library) the column named ID.

Cheers!