Share via


Powershell script to get Site Collection. Site Owner, Title

Question

Monday, April 13, 2015 7:27 AM

Hi,

I am new to SharePoint, currently I have given one task to create the powershell script which contains the below fields from our two farms. Could you please help me out with the same.

The script to list out below items:

Site Collections:
Site Collection Name:
Site Collection Owners:
Last Activity and the size of site collections.

Many Thanks & Best Regards,

Naren

All replies (6)

Monday, April 13, 2015 7:38 AM âś…Answered

Hello Narender,

"The powershell command to get all site collection information is Get-SPSite. You can combine it with Get-SPWebApplication to target it and use Select with pipe to refine the output. You can explore the Select as there are may other attributes available than the ones I listed."

Get-SPWebApplication http://mywebapp | Get-SPSite | Select ID, Url | Export-Clixml c:\mysitecollectioninfo.xml

Please see similar thread below.

https://social.technet.microsoft.com/Forums/sharepoint/en-US/c6dd2041-3b8d-4d2e-9dcf-a8b083deb18d/powershell-site-collections-size-owner-last-used-etc?forum=sharepointgeneralprevious

My Blog- http://www.sharepoint-journey.com|
If a post answers your question, please click Mark As Answer on that post and Vote as Helpful


Monday, April 13, 2015 7:45 AM | 1 vote

Very simple one:

$a = Get-SPWebApplication http://WEBAPP | Get-SPSite -Limit ALL

foreach ($i in $a)
{

$i | Select URL, Owner, @{Name="Size"; Expression={$_.Usage.Storage/1MB}}

}

If this is helpful please mark it so. Also if this solved your problem mark as answer.


Monday, April 13, 2015 7:53 AM

To get all Site Collections:

If all you want is a list of all site collections in the farm, all you have to do is open a PowerShell window, load the SharePoint Snapin, if you haven't (Add-PSSnapin Microsoft.SharePoint.PowerShell), and type Get-SPSite.

If you want to return the list of site collections for a specific web application, the easiest way is to just pipe it as Get-SPWebApplication http://intranet | Get-SPSite

To get Site Collection Owners:

Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

Get-SPWebApplication "http://mySharePointSite.com"| Get-SPSite| foreach-object{ Write-host$_.Url - $_.Owner.Email}

To get Size of all Site Collections:

Get-SPSite | select url, @{label"Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html -title "Site Collections sort by size" | Set-Content sc.html

Regrading the retrieving the last activity I am not sure to what exactly you are looking for but I assume you are concern about getting users last logon time and date using PowerShell.

For this refer here: Get Users Last Logon Time and Date using PowerShell


Please remember to upvote if it helps you or click 'Mark as Answer' if the reply answers your query.


Monday, April 13, 2015 9:48 AM

Thanks Devendra :)

I used the reference link you provided and found this blog very useful.

Windows PowerShell Script to Output Site Collection Information


Monday, April 13, 2015 9:52 AM

Thanks Zakir :)

I found the script from Technet article

http://blogs.technet.com/b/fromthefield/archive/2013/07/25/windows-powershell-script-to-output-site-collection-information.aspx


Monday, April 13, 2015 9:53 AM

Thanks :)

I found the script from Technet article

http://blogs.technet.com/b/fromthefield/archive/2013/07/25/windows-powershell-script-to-output-site-collection-information.aspx