How to use PowerShell to analyze SharePoint WebApplication architecture

Source: Internet
Author: User
Tags foreach

A previous article, "Two diagrams to see the SharePoint 2013 Farm logical architecture," talked about the relationship between Web Application,content database,site collection. With this logical structure diagram, this article will use PowerShell to more visually demonstrate the architecture of the SharePoint WebApplication.

SharePoint WebApplication Structure

As you can see from the illustration above, a webapplication can contain multiple content Database, and you can use PowerShell to view the content Databases that WebApplication contains.

Add-pssnapin Microsoft.SharePoint.PowerShell  
      
#Get-spwebapplication | get-member#  
      
get-spwebapplication  |%{  
      
    write-host "' N-$ ($_. URL) ";  
    foreach ($cd in $_. contentdatabases) {  
        write-host "$ ($cd. Name) "
    }  
}

You can certainly get more accurate data, such as the size of the content database

Add-pssnapin Microsoft.SharePoint.PowerShell  
get-spwebapplication  |%{write-output "' N-$ ($_. URL) "; foreach ($cd in $_. contentdatabases) {  
   $ContentDatabaseSize = [Math]::round ($CD. DISKSIZEREQUIRED/1GB), 2)   
   Write-output " contentname:$ ($CD. Name) ' n size:$ ($ContentDatabaseSize) G "
 }}

After you have obtained the content database, you can continue to delve into it, such as the site Collection contained in the content database, as well as a line of Poweshell to get.

Add-pssnapin Microsoft.SharePoint.PowerShell  
      
#Get-spcontentdatabase | get-member#  
      
get-spcontentdatabase |%{write-output "' N-$ ($_. Name) "; foreach ($site in $_. Sites) {write-output "$ ($site. URL) "}}   >>c:\xx2.txt

Of course, you can also get the site collection size, the same way as the content database size, the same line PowerShell implementation.

Add-pssnapin Microsoft.SharePoint.PowerShell  
      
get-spwebapplication |%{write-output "' N-$ ($_. URL) "; $_. Sites | Select URL, @{label= "Size in MB"; Expression={[math]::round ($_.usage.storage/1mb,2)}}| Sort-object-descending-property "Size in MB"}>>c:\tt.txt

Author: cnblogs Wood Wancheng Master

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/web/sharepoint/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.