Providing Technology Training and Mentoring For Modern Technology Adoption
Let’s say we have to display SharePoint site collection size using PowerShell. We can easily use Client Object Model and PowerShell to accomplish that. Let’s do it step by step:
PS > $spsite = Get-SPSite “http://sharepoint:100”
PS > $spsite.Usage
It will display data like this:
Hmmm, interesting. It shows the size and also some other user information like visits and bandwidth. But, we just care for the size. So let’s modify the code:
PS > $spsite.Usage.Size
Ok, we have the size but it’s in bytes. Let’s convert that to MB.
The output looks like this:
Still doesn’t look good. Now we can use the expression formatting to make it human friendly:
Bingo, now it shows up as:
0:N2 is the standard .NET based format. 0 would means the argument position and N2 means number format with 2 decimal places. –f is used for pass the argument to the format.
Awesome. and Thanks for explaining so clearly.
Your email address will not be published. Required fields are marked *