Posts

Showing posts from June, 2016

Get Site Collection URL Content DataBase name and Size with PowerShell

Add-PSSnapin   microsoft.sharepoint.powershell $SizeLog   =   "D:\temp\SPSiteSize.csv" ############################################################ $CurrentDate   =   Get-Date   -format   d $WebApps   =   Get-SPWebApplication foreach ( $WebApp   in   $WebApps ) {   $Sites   =   Get-SPSite   -WebApplication   $WebApp   -Limit   All   foreach ( $Site   in   $Sites ) {   $SizeInKB   =   $Site . Usage . Storage   $SizeInGB   =   $SizeInKB / 1024 / 1024 / 1024   $SizeInGB   =   [ math ]:: Round( $SizeInGB , 2 )   $CSVOutput   =   $Site . RootWeb . Title  +   "*"   +   $Site . URL  +   "*"   +   $Site . ContentDatabase . Name  +   "*"   +   $SizeInGB   +   "*"   +   $CurrentDate   $CSVOutput   |   Out-File   $SizeLog   -Append } } $Site . Dispose()

Export SharePoint List Item Version History to Excel

I wrote a PowerShell script and C# object model codes to generate SharePoint version history report in  SharePoint document version history report , related to that, got a new requirement to export version history to excel. This version history report helps to compare what data is changed, who changed the list data, etc over time.  just replace the values of WebURL, ListName variables with your Site/List values and run the script to export version history SharePoint 2013 # ******* Variables Section ****************** #Define these variables $WebURL = "http://sharepoint. constsco. com/sites/Sales/" $ListName   = "Invoice" $ReportFile   =  "D:\Invoice_VersionHistory.csv" # ********************************************* #delete file if exists If ( Test-Path   $ReportFile )   {   Remove-Item   $ReportFile   } #Get the Web and List $Web   = Get -SPWeb   $WebURL $List   =  $web .Lists.TryGetList( $ListName )   #Check if lis

SharePoint 2010: List and Delete List Item Versions using PowerShell

Image
Introduction When versioning is turned on for a SharePoint list or document library, there are times when you may need to report on the number of list item versions, or delete versions that exceed a threshold. These scenarios can happen if; 1. Version limits (for the maximum number of major/minor versions) were not set, and the list has too many versions 2. Version limits are being applied or reduced, and you need to retrospectively delete all the versions in a list that exceed the new threshold* 3. You are performing an upgrade, and you want to prune the versions of pages in the pages library (on a publishing site) 4. You want to run a report to determine how many items in a list have more than "x" number of versions  *When the version settings are changed on a list, existing versions on existing items in the list are not changed until the item is modified. Therefore, if you reduce the maximum number of versions to be kept for items in a list, the changes only take effec