To monitor SharePoint databases, first use the following commandlet to retrieve the list of databases:
The preceding command displays all SharePoint web applications available in this farm, along with their respective database names and SQL server name.
To check the current size (in bytes) of each site collection, use the following cmdlet:
The sample might look complicated but actually gets all the site collections and formats the output to make it easy to read. Here are a few notes:
• SPSite.Usage
property is a complex object, and to retrieve storage usage we had to construct an expression.
• A similar expression was used to retrieve quota properties.
• An expression also demonstrates PowerShell’s capability to convert results to HTML and save it to a file (ConvertTo-HTML | Out – File
).
• Figure 7.8 shows sample results that could be retrieved by running such a command in CompanyABC’s farm.
Figure 7.8. Displaying results of PowerShell cmdlet in a GridView
format.
Set-SPSite
also gives you the ability to change quotas for a site collection via PowerShell. To change a quota for a site collection, type this ("My Quota Template"
uses the name of an existing quota template available in your farm. A new template can be created via central administration):
Set-SPSite "http://portal.companyABC.com" –QuotaTemplate "My Quota Template"