-
Notifications
You must be signed in to change notification settings - Fork 0
/
Privatesites Storage script.ps1
64 lines (49 loc) · 2.17 KB
/
Privatesites Storage script.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#Config Parameters
$AdminSiteURL = "https://YOURDOMAIN-admin.sharepoint.com"
$ReportOutput = "C:\Temp\SPOStorage.csv"
#Connect to SharePoint Online Admin Center
Connect-PnPOnline -Url $AdminSiteURL -Interactive
#Get all Private sites and private channel sites
$PrivateChannelSite = Get-PnPTenantSite -Template "TEAMCHANNEL#1"
$private = Get-PnPMicrosoft365Group -IncludeSiteUrl | Where-Object { $_.Visibility -eq "Private" }
#Save them in an array for later
$ResultSet = @()
#For private sites
Foreach ($Site in $private) {
#Send the Result to CSV
$Result = new-object PSObject
$Result | add-member -membertype NoteProperty -name "SiteURL" -Value $Site.siteurl
$ResultSet += $Result
}
#For $Private Channel Site
Foreach ($S in $PrivateChannelSite) {
#Send the Result to CSV
$Result = new-object PSObject
$Result | add-member -membertype NoteProperty -name "SiteURL" -Value $S.url
$ResultSet += $Result
}
#Compiled all sites in an object
$SiteCollections = $ResultSet.SiteURL
#counter
$i = 1
#Array to store final Result
$ResultS = @()
foreach ($SiteURL in $SiteCollections) {
#Get the Site collection Storage Metrics
if ($null -ne $SiteURL ) {
$details = Get-PnPTenantSite -Url $SiteURL
$i
$i++
Write-Host "Processing Site Collection :" $details.URL -f Yellow
#Send the Result to CSV
$obj = new-object PSObject
$obj | add-member -membertype NoteProperty -name "SiteURL" -Value $details.URL
$obj | add-member -membertype NoteProperty -name "Allocated" -Value $details.StorageQuota
$obj | add-member -membertype NoteProperty -name "Used" -Value $details.StorageUsageCurrent
$obj | add-member -membertype NoteProperty -name "Warning Level" -Value $details.StorageQuotaWarningLevel
$ResultS += $obj
}
}
#Export Result to csv file
$ResultS | Export-Csv $ReportOutput -notypeinformation
Write-Host "Site Quota Report Generated Successfully!" -f Green