Skip to content

Commit

Permalink
Merge pull request #717 from reshmee011/StorageQuota
Browse files Browse the repository at this point in the history
Sample script for monitoring storage against quota
  • Loading branch information
pkbullock committed Jul 29, 2024
2 parents 97b1e70 + 19fbf27 commit 9fbb0e4
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 37 deletions.
37 changes: 0 additions & 37 deletions README.md

This file was deleted.

45 changes: 45 additions & 0 deletions scripts/spo-get-sharepoint-storage-currentquota/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
plugin: add-to-gallery
---

# Get SharePoint Storage Usage Against Allocated Quota

## Summary

There is limited space allocated to the tenant. To ensure business continuity and smooth ongoing operation, it is imperative to keep an eye on its usage and take relevant actions suited to the circumstances. By default a SharePoint site is allocated 25 TB by default and OneDrive for Business site is allocated 1 TB by default. These settings can be amended manually to a different quota to control SharePoint site. The script will help to proactively monitor percent used against quota for each SharePoint site.

![Example Screenshot](assets/example.png)

### Prerequisites

- The user account that runs the script must have SharePoint Online tenant administrator access.

# [PnP PowerShell](#tab/pnpps)

```powershell
connect-pnpOnline -url https://contoso-admin.sharepoint.com/ -Interactive
$reportPath = "c:\temp\storage.csv"
Get-PnPTenantSite -IncludeOneDriveSites | Sort-Object StorageUsageCurrent -Descending | Select-Object Url, @{Name='StorageUsageCurrent (GB)'; Expression={$_.StorageUsageCurrent / 1024}}, @{Name='StorageQuota (GB)'; Expression={$_.StorageQuota / 1024}}, @{Name='% Used'; Expression={'{0:P2}' -f ($_.StorageUsageCurrent / $_.StorageQuota)}} | Select-Object -First 10| export-csv $reportPath -notypeinformation
# Omit `Select-Object -First 10` if all sites need to be monitored.
# omit the parameter -IncludeOneDriveSites to exclude OneDrive sites
```

[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]

***

## Source Credit

Sample first appeared on [SharePoint Storage Monitoring Against Allocated Quota using PowerShell](https://reshmeeauckloo.com/posts/PowerShell-SharePoint-Storage-Reporting/)

## Contributors

| Author(s) |
|-----------|
| [Reshmee Auckloo](https://github.com/reshmee011) |


[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-get-sharepoint-storage-currentquota" aria-hidden="true" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions scripts/spo-get-sharepoint-storage-currentquota/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"name": "spo-get-sharepoint-storage-currentquota",
"source": "pnp",
"title": "Get SharePoint Storage Usage Against Allocated Quota",
"shortDescription": "Understand and sharing links activities within your M365 environment is crucial for maintaining security and compliance.",
"url": "https://pnp.github.io/script-samples/spo-get-sharepoint-storage-currentquota/README.html",
"longDescription": [
"it is imperative to keep an eye on its usage and take relevant actions suited to the circumstances. By default a SharePoint site is allocated 25 TB by default and OneDrive for Business site is allocated 1 TB by default. These settings can be amended manually to a different quota to control SharePoint site. The script will help to proactively monitor percent used against quota for each SharePoint site."
],
"creationDateTime": "2024-07-28",
"updateDateTime": "2024-07-28",
"products": [
"SharePoint"
],
"metadata": [
{
"key": "PNP-POWERSHELL",
"value": "2.5.2"
}
],
"categories": [
"Report"
],
"tags": [
"modern",
"Connect-PnPOnline",
"Get-PnPTenantSite"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-get-sharepoint-storage-currentquota/assets/preview.png",
"alt": ""
}
],
"authors": [
{
"gitHubAccount": "reshmee011",
"company": "",
"pictureUrl": "https://avatars.githubusercontent.com/u/7693852?v=4",
"name": "Reshmee Auckloo"
}
],
"references": [
{
"name": "Want to learn more about PnP PowerShell and the cmdlets",
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
"url": "https://aka.ms/pnp/powershell"
},
{
"name": "Want to learn more about CLI for Microsoft 365 and the commands",
"description": "Check out the CLI for Microsoft 365 site to get started and for the reference to the commands.",
"url": "https://aka.ms/cli-m365"
}
]
}
]

0 comments on commit 9fbb0e4

Please sign in to comment.