#--------------------------------------------------------------------------------------------------------------------------------------------
# Author: Shiv Mangal Singh
# Date: May 26, 2016
# Description: This script is used to get SharePoint Document Library's Versions(total number of version created,latest version size, versions size, total versions size) Size Report across Web Application.
# Syntax $WebAppURL --> WebApplication Name | $FileUrl--> CSV file location
# e.g: .\Get_DocumentLibraryVersionReport_WebApplication.ps1
#--------------------------------------------------------------------------------------------------------------------------------------------
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
Function GenerateVersionSizeReport($WebAppURL, $FileUrl)
{
#Get the Web Application
$WebApp = Get-msSite -WebApplication $WebAppURL -limit all
#Write the CSV Header - Tab Separated
"Site Name`t Library `t File Name `t File URL `t File Type `t Last Modified `t No. of Versions `t Latest Version Size(MB) `t Versions Size(MB) `t Total File Size(MB)" | Out-File $FileUrl -Append
#Loop through each site collection
foreach($Site in $WebApp)
{
#Loop through each site in the site collection
foreach($Web in $Site.AllWebs)
{
#Loop through each List
foreach ($List in $Web.Lists)
{
Write-Host $List.Title
#Get only Document Libraries & Exclude Hidden System libraries
if ( ($List.BaseType -eq "DocumentLibrary") -and ($List.Hidden -eq $false) )
{
foreach ($ListItem in $List.Items)
{
#Consider items with 1+ versions
if ($ListItem.Versions.Count -gt 1)
{
$versionSize=0
#Get the versioning details
foreach ($FileVersion in $ListItem.File.Versions)
{
$versionSize = $versionSize + $FileVersion.Size;
}
#To Calculate Total Size(MB)
$ToalFileSize= [Math]::Round(((($ListItem.File.Length + $versionSize)/1024)/1024),2)
#Convert Size to MB
$VersionSize= [Math]::Round((($versionSize/1024)/1024),2)
#Get the Size of the current version
$CurrentVersionSize= [Math]::Round((($ListItem.File.Length/1024)/1024),2)
#Get Site Name
if ($Web.IsRootWeb -eq $true)
{
$siteName = $Web.Title +" - Root";
}
else
{
$siteName= $Site.RootWeb.Title + " - " + $Web.Title;
}
#Log the data to a CSV file where versioning size > 0MB!
if ($versionSize -gt 0)
{
"$($siteName) `t $($List.Title) `t $($ListItem.Name) `t $($Web.Url)/$($ListItem.Url) `t $($ListItem['File Type'].ToString()) `t $($ListItem['Modified'].ToString())`t $($ListItem.Versions.Count) `t $CurrentVersionSize `t $($versionSize) `t $($ToalFileSize)" | Out-File $FileUrl -Append
}
}
}
}
}
$Web.Dimsose()
}
$Site.Dimsose()
}
#Send message to console
# write-host "Versioning Report Generated Successfully!"
}
#Call the Function to Generate Version History Report
GenerateVersionSizeReport "https://ms.contoso.net/" "D:\contosomsSSU_MWTeam\Shiv\versionreportNew.csv"
# Author: Shiv Mangal Singh
# Date: May 26, 2016
# Description: This script is used to get SharePoint Document Library's Versions(total number of version created,latest version size, versions size, total versions size) Size Report across Web Application.
# Syntax $WebAppURL --> WebApplication Name | $FileUrl--> CSV file location
# e.g: .\Get_DocumentLibraryVersionReport_WebApplication.ps1
#--------------------------------------------------------------------------------------------------------------------------------------------
# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
Function GenerateVersionSizeReport($WebAppURL, $FileUrl)
{
#Get the Web Application
$WebApp = Get-msSite -WebApplication $WebAppURL -limit all
#Write the CSV Header - Tab Separated
"Site Name`t Library `t File Name `t File URL `t File Type `t Last Modified `t No. of Versions `t Latest Version Size(MB) `t Versions Size(MB) `t Total File Size(MB)" | Out-File $FileUrl -Append
#Loop through each site collection
foreach($Site in $WebApp)
{
#Loop through each site in the site collection
foreach($Web in $Site.AllWebs)
{
#Loop through each List
foreach ($List in $Web.Lists)
{
Write-Host $List.Title
#Get only Document Libraries & Exclude Hidden System libraries
if ( ($List.BaseType -eq "DocumentLibrary") -and ($List.Hidden -eq $false) )
{
foreach ($ListItem in $List.Items)
{
#Consider items with 1+ versions
if ($ListItem.Versions.Count -gt 1)
{
$versionSize=0
#Get the versioning details
foreach ($FileVersion in $ListItem.File.Versions)
{
$versionSize = $versionSize + $FileVersion.Size;
}
#To Calculate Total Size(MB)
$ToalFileSize= [Math]::Round(((($ListItem.File.Length + $versionSize)/1024)/1024),2)
#Convert Size to MB
$VersionSize= [Math]::Round((($versionSize/1024)/1024),2)
#Get the Size of the current version
$CurrentVersionSize= [Math]::Round((($ListItem.File.Length/1024)/1024),2)
#Get Site Name
if ($Web.IsRootWeb -eq $true)
{
$siteName = $Web.Title +" - Root";
}
else
{
$siteName= $Site.RootWeb.Title + " - " + $Web.Title;
}
#Log the data to a CSV file where versioning size > 0MB!
if ($versionSize -gt 0)
{
"$($siteName) `t $($List.Title) `t $($ListItem.Name) `t $($Web.Url)/$($ListItem.Url) `t $($ListItem['File Type'].ToString()) `t $($ListItem['Modified'].ToString())`t $($ListItem.Versions.Count) `t $CurrentVersionSize `t $($versionSize) `t $($ToalFileSize)" | Out-File $FileUrl -Append
}
}
}
}
}
$Web.Dimsose()
}
$Site.Dimsose()
}
#Send message to console
# write-host "Versioning Report Generated Successfully!"
}
#Call the Function to Generate Version History Report
GenerateVersionSizeReport "https://ms.contoso.net/" "D:\contosomsSSU_MWTeam\Shiv\versionreportNew.csv"
Hire trusted and affordable Packers and Movers Ahmedabad at doorstep delivery with best quality packing for your home shifting, office relocation, car carriers, bike transportation services within Ahmedabad locality, outside Ahmedabad city and international movers from Ahmedabad.
ReplyDeletehttp://www.packersandmoversahmedabad.in
http://www.packersandmoversahmedabad.in/packers-and-movers-vapi.html
http://www.packersandmoversahmedabad.in/packers-and-movers-valsad.html
http://www.packersandmoversahmedabad.in/packers-and-movers-rajkot.html
http://www.packersandmoversahmedabad.in/packers-and-movers-bharuch.html
http://www.packersandmoversahmedabad.in/packers-and-movers-bhavnagar.html
http://www.packersandmoversahmedabad.in/packers-and-movers-jamnagar.html
http://www.packersandmoversahmedabad.in/packers-and-movers-gandhinagar.html
http://www.packersandmoversahmedabad.in/packers-and-movers-gandhidham.html