powershell
2224 TopicsTotal Size of Preservation Hold Libraries
Hello All, I am wondering if someone can help with a PowerShell script to retrieve the size of Preservation hold libraries in all the SharePoint Sites and OneDrive. I need to calculate the total space being used by items in Preservation Hold Libraries in our tenant. Thanks so much for the help in advance.15KViews0likes7CommentsAutomating SharePoint Site Status Reporting with PowerShell
Introduction Migrating Microsoft 365 workloads is a critical step during organizational transitions such as mergers or de‑mergers. SharePoint site collections often contain business‑critical data, and ensuring visibility into their readiness is essential for a smooth migration. To address this, I developed a PowerShell script that automatically generates a SharePoint Site Status Report, categorizing sites into Active, Read‑Only, and Offline. This report provides administrators and migration engineers with actionable insights to plan and execute migrations confidently. Why This Matters Visibility: Quickly assess site readiness across all web applications. Governance: Ensure compliance and proper access controls. Efficiency: Automate reporting to reduce manual effort. Risk Mitigation: Identify offline or read‑only sites before migration. How It Works The script leverages the SharePoint Management Shell and runs under the Farm Account with elevated permissions. It performs the following steps: Loads SharePoint cmdlets. Iterates through all web applications. Categorizes sites into Active, Read‑Only, and Offline. Compiles results into a structured CSV/Excel/HTML report. Sends the report via email to stakeholders. Key PowerShell Cmdlets Add-PSSnapin Microsoft.SharePoint.PowerShell Get-SPWebApplication Get-SPSite -WebApplication -Limit All $site.ReadOnly / $site.Status Export-Csv Send-MailMessage Parameters to Replace Before running the script, update these placeholders: SMTP Server → mail.company.com → replace with your mail server Sender Address ($from) → email address removed for privacy reasons → replace with reporting account Recipient Address ($to) → email address removed for privacy reasons → replace with stakeholder distribution list Email Subject ($subject) → "SharePoint Site Status Report" → customize for clarity Report File Path ($csvPath) → C:\Reports\SharePoint_SiteStatusReport.csv → replace with desired location Web Application URLs → ensure correct farm references Execution Context → must run under Farm Account Conclusion This automated reporting solution provides clarity, governance, and efficiency during SharePoint migrations. By categorizing sites and delivering structured reports, administrators can prioritize tasks, mitigate risks, and ensure a seamless transition to Microsoft 365. Code: #Adding Snapin for SharePoint #Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue $TodayDate =Get-Date Write-Host $TodayDate $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } ##My Connect # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # # WebSites $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # ##Websites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # ## Websites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # ##FGC-SalesShareWebSites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } ##WebSites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } ##WebSites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } ##WebSites # $FileName = "C:\Results_Active_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_Readonly_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } # $FileName = "C:\Results_NoAccess_WebSites.txt" if (Test-Path $FileName) { Remove-Item $FileName } Add-PSSnapin Microsoft.SharePoint.Powershell [string[]]$WebapplicationList = "" Foreach($Webapp in $WebapplicationList) { Write-Host $Webapp $displaywebappname=Get-SPWebApplication $webapp $webappname=$displaywebappname.name Write-Host $webappname $Sites = Get-SPWebApplication $webapp | Get-SPSite -limit all | foreach { if ($_.ReadOnly -eq $false -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false) { $Result =”Site is Active” $save2= "Results_Active_${webappname}.txt" #Write-Host $save2 $saveCSVactive="Results_Active_${webappname}.csv" $_.RootWeb.Title +”`t” + $_.URL + “`t” + $Result | Out-File $save2 -append #$_.RootWeb.Title +”`t” + $_.URL + “`t” + $Result | Out-File $saveCSVactive -Append } elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $true) { $Result = “Site is Read-Only” $save1= "Results_Readonly_${webappname}.txt" $_.RootWeb.Title +”`t” + $_.URL + “`t” + $Result | Out-File $save1 -Append } elseif ($_.ReadOnly -eq $null -and $_.ReadLocked -eq $null -and $_.WriteLocked -eq $null) { $Result=”Site status is No Access” $save3= "Results_NoAccess_${webappname}.txt" #$_.RootWeb.Title +”`t” + $_.URL + “`t” + $Result | Out-File $save3 -Append $_.URL +”`t” + $_.RootWeb.Title + “`t” + $Result | Out-File $save3 -Append } } } $TodayDate =Get-Date Write-Host $TodayDate sleep -Seconds 100 #Active Sites WebSites $ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object Write-Host "Websites Active sites" $ActiveSites_Websites.count $Websites_ActiveSitescount = $ActiveSites_Websites.count #Read-only Sites WebSites $ReadonlySites_Websites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count $Websites_Readonlysitescount=$ReadonlySites_Websites.count #No-Access Sites WebSites $NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count $Websites_NoAccessSitesCount=$NoaccessSies_Websites.count #Active Sites WebSites $ActiveSites_WebSites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object Write-Host "WebSites Active sites" $ActiveSites_WebSites.count $WebSites_ActiveSitescount = $ActiveSites_WebSites.count #Read-only Sites WebSites #$Readonlysite_WebSites =Get-Content -Path C:\Results_Readonly_Websites.txt | Measure-Object #If($Readonlysite_WebSites -eq $null) #{ #$WebSites_Readonlysitecount ="0" #} #else{ $Readonlysite_WebSites =Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object Write-Host "WebSites Readonly Sites" $Readonlysite_WebSites.count $WebSites_ReadonlySitesCount= $Readonlysite_WebSites.count # Write-Host $WebSites_ReadonlySitesCount #} #WebSites - No Access Sites #$NoAccessSites_WebSites= Get-Content -Path "C:\Results_NoAccess_Websites.txt" $NoAccessSites_WebSites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object Write-Host "WebSites NoAccess Sites" $NoAccessSites_WebSites.count # #Write-Host "Site Count $($NoAccessSites_WebSites.Count)" $WebSites_NoAccessSitesCount= $NoAccessSites_WebSites.count ################################################################## # #Active Sites Websites $ActiveSites_WebSites= Get-Content -Path "C:\Results_Active_Websites.txt" | Measure-Object Write-Host "WebSites Active sites" $ActiveSites_WebSites.count $WebSites_ActiveSitescount = $ActiveSites_WebSites.count # # #Read-only Sites WebSites $ReadonlySites_WebSites=Get-Content -Path "C:\Results_Readonly_Websites.txt" | Measure-Object Write-Host "WebSites Read-only Sites" $ReadonlySites_WebSites.count $WebSites_Readonlysitescount=$ReadonlySites_WebSites.count # # #No-Access Sites WebSites $NoaccessSies_WebSites= Get-Content -Path "C:\Results_NoAccess_Websites.txt" | Measure-Object Write-Host "WebSites No-Access Sites" $NoaccessSies_WebSites.count $WebSites_NoAccessSitesCount=$NoaccessSies_WebSites.count # # #Active Sites Websites $ActiveSites_WebSites= Get-Content -Path "C:\Results_Active_Websites.txt" | Measure-Object Write-Host "WebSites Active sites" $ActiveSites_WebSites.count $WebSites_ActiveSitescount = $ActiveSites_WebSites.count # # #Read-only Sites WebSites $ReadonlySites_WebSites=Get-Content -Path "C:\Results_Readonly_Websites.txt" | Measure-Object Write-Host "WebSites Read-only Sites" $ReadonlySites_WebSites.count $WebSites_Readonlysitescount=$ReadonlySites_WebSites.count # # #No-Access Sites WebSites $NoaccessSies_WebSites= Get-Content -Path "C:\Prod\Results_NoAccess_Websites.txt" | Measure-Object Write-Host "WebSites No-Access Sites" $NoaccessSies_WebSites.count $WebSites_NoAccessSitesCount=$NoaccessSies_WebSites.count # # #WebSites # # #Active Sites WebSites ##$ActiveSites_WebSites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "WebSites Active sites" $ActiveSites_WebSites.count ##$WebSites_ActiveSitescount = $ActiveSites_WebSites.count # # #Read-only Sites WebSites ##$ReadonlySites_WebSites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "WebSites Read-only Sites" $ReadonlySites_WebSites.count ##$WebSites_Readonlysitescount=$ReadonlySites_WebSites.count # # #No-Access Sites WebSites ##$NoaccessSies_WebSites= Get-Content -Path "C:\Results_NoAccess_WebSites" | Measure-Object ##Write-Host "WebSites No-Access Sites" $NoaccessSies_WebSites.count ##$WebSites_NoAccessSitesCount=$NoaccessSies_WebSites.count # # #WebSites # # #Active Sites WebSites ##$ActiveSites_WebSites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "WebSites Active sites" $ActiveSites_WebSites.count ##$WebSites_ActiveSitescount = $ActiveSites_WebSites.count # # #Read-only Sites WebSites ##$ReadonlySites_WebSites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "WebSites Web Read-only Sites" $ReadonlySites_WebSites.count ##$WebSites_Readonlysitescount=$ReadonlySites_WebSites.count # # #No-Access Sites WebSites ##$NoaccessSies_WebSites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "WebSites Web No-Access Sites" $NoaccessSies_WebSites.count ##$WebSites_NoAccessSitesCount=$NoaccessSies_WebSites.count # # #Websites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ##$ReadonlySites_Websites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount=$ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count # # #Websites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ##$ReadonlySites_Websites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount= $ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $$NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count # # #Websites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ##$ReadonlySites_Websites=Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount=$ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count # #WebSites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ##$ReadonlySites_Websites= Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount=$ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count # #WebSites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ##Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ##$ReadonlySites_Websites= Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount=$ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count # #WebSites # # #Active Sites Websites ##$ActiveSites_Websites= Get-Content -Path "C:\Results_Active_WebSites.txt" | Measure-Object ## Write-Host "Websites Active sites" $ActiveSites_Websites.count ##$Websites_ActiveSitescount = $ActiveSites_Websites.count # # #Read-only Sites Websites ## $ReadonlySites_Websites= Get-Content -Path "C:\Results_Readonly_WebSites.txt" | Measure-Object ##Write-Host "Websites Read-only Sites" $ReadonlySites_Websites.count ##$Websites_Readonlysitescount=$ReadonlySites_Websites.count # # #No-Access Sites Websites ##$NoaccessSies_Websites= Get-Content -Path "C:\Results_NoAccess_WebSites.txt" | Measure-Object ##Write-Host "Websites No-Access Sites" $NoaccessSies_Websites.count ##$Websites_NoAccessSitesCount=$NoaccessSies_Websites.count $TotalActiveSite = ($Websites_ActiveSitescount + $WebSites_ActiveSitescount + $WebSites_ActiveSitescount + $WebSites_ActiveSitescount + $WebSites_ActiveSitescount + $WebSites_ActiveSitescount + $Websites_ActiveSitescount + $CTLQwest_ActiveSitescount + $RecordsCenter_ActiveSitescount + $Websites_ActiveSitescount + $Websites_ActiveSitescount + $Websites_ActiveSitescount + $Websites_ActiveSitescount + $Websites_ActiveSitescount) $TotalReadonlySites = ($Websites_Readonlysitescount + $WebSites_ReadonlySitesCount + $WebSites_Readonlysitescount + $WebSites_Readonlysitescount + $WebSites_Readonlysitescount + $WebSites_Readonlysitescount + $Websites_Readonlysitescount + $Websites_Readonlysitescount + $Websites_Readonlysitescount + $Websites_Readonlysitescount + $Websites_Readonlysitescount + $Websites_Readonlysitescount) $TotalNoAccessSite = ($Websites_NoAccessSitesCount + $WebSites_NoAccessSitesCount + $WebSites_NoAccessSitesCount + $WebSites_NoAccessSitesCount + $WebSites_NoAccessSitesCount + $WebSites_NoAccessSitesCount + $Websites_NoAccessSitesCount + $Websites_NoAccessSitesCount + $Websites_NoAccessSitesCount + $Websites_NoAccessSitesCount + $Websites_NoAccessSitesCount + $Websites_NoAccessSitesCount) #Total Sites $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_Readonlysitescount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_ReadonlySitesCount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_Readonlysitescount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_Readonlysitescount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_Readonlysitescount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($WebSites_ActiveSitescount + $WebSites_Readonlysitescount + $WebSites_NoAccessSitesCount) $TotalWebSites = ($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) $TotalWebSites = ($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) $TotalWebSites =($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) $TotalWebSites = ($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) $TotalWebSites = ($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) $TotalWebSites = ($Websites_ActiveSitescount + $Websites_Readonlysitescount + $Websites_NoAccessSitesCount) #====== All Sites Count $TotalSites =($TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites + $TotalWebSites) #Sending Email #================ #[string[]]$recipients = "" $recipients11 = @("") #[string[]]$recipients = "" # "" $smtp = "smtp" #$to = $recipients11 $from = "" #$from = "" $subject = "SharePoint Sites Current Status" $body = " <b> <font color=Navy> Date -$todaydate </b> </font> <br>" #$attachment11="C:\Results_Active_Web.txt","C:\Results_Active_Web.txt" #$body = " <b><font color=red> SP-Apps Read-only Sites Count - $Readonlysitecount </b></font> <br>" #$body += " <b><font color=red> SP-Apps Active Sites Count - $ActiveSitescount </b></font> <br>" #$body += " <b><font color=red> SP-Apps No-Access Sites Count - $NoAccessSiteCount </b></font> <br>" #$body += "Click <a href=http://www.google.com>here</a> to open google <br>" #### Now send the email using \> Send-MailMessage #========= $report = "<html> <style> {font-family: Arial; font-size: 15pt;color: #F70707; } {color:#F70707;} TABLE{border: 1px solid black; border-collapse: collapse; font-size:15pt;} #TH{border: 1px solid black; background: #F4D03F; padding: 5px; color: #000000;} TR{color: #2E86C1;text-align: center;background: #13B5ED; padding: 5px; color: #0F0F0F;} TR{color: #2E86C1;text-align: center;background: #13B5ED; padding: 5px; color: #0F0F0F;} TH{border: 1px solid black; background: #F4D03F; padding: 5px; color: #F70707;} TD{border: 1px solid black; padding: 5px; } H2{color: #F70707;} H1{Color: #0C0B0A;} </style> <h1> SharePoint Sites Current Status</h1> <table> <tr> <td> <b> Web Application </b> </td> <td> <b> Active Sites </b> </td> <td> <b> Read-Only Sites </b> </td> <td> <b> No-Access (Locked) Sites </b></td> <td> <b> Total Sites </b> </td> <tr> <tr> <td> <b> Web Application </b> </td> <td> $Web_ActiveSitescount </td> <td> $Web_Readonlysitescount</td> <td> $Web_NoAccessSitesCount </td> <td> <b> $TotalWebSites </b> </td> </tr> <tr> <td> <b> Web Application </b> </td> <td> $Web_ActiveSitescount </td> <td> $Web_ReadonlySitesCount</td> <td> $Web_NoAccessSitesCount </td> <td> <b> $TotalWebSites </b> </td> </tr> <tr> <td> <b> Web Application </b> </td> <td> $Web_ActiveSitescount </td> <td> $Web_Readonlysitescount </td> <td> $Web_NoAccessSitesCount </td> <td> <b> $TotalWebSites </b> </td> </tr> <tr> <td> <b> Web Application </b> </td> <td> $Web_ActiveSitescount </td> <td> $Web_Readonlysitescount </td> <td> $Web_NoAccessSitesCount </td> <td> <b> $TotalWebSites </b> </td> </tr> </tr> </table> " $report1 = "<html> <style> {font-family: Arial; font-size: 12pt;color: #0F0F0F; } {color:#F70707;} TABLE{border: 1px solid black; border-collapse: collapse; font-size:15pt;} #TH{border: 1px solid black; background: #F4D03F; padding: 5px; color: #000000;} TR{color: #F70707;text-align: center;background: #13B5ED; padding: 5px; color: #0F0F0F;} TR{color: #F70707;text-align: center;background: #13B5ED; padding: 5px; color: #0F0F0F;} TH{border: 1px solid black; background: #F4D03F; padding: 5px; color: #F70707;} TD{border: 1px solid black; padding: 5px; } H2{color: #F70707;} H1{Color: #0C0B0A;} </style> <table> <tr> <td> <b>Total Active Sites Count </b> </td> <td> <b> Total Read-Only Sites Count </b> </td> <td> <b> Total NoAccess Sites Count </b> </td> <td> <b> Total Sites </b> </td> </tr> <tr> <td> <b> $TotalActiveSite </b> </td> <td> <b> $TotalReadonlySites </b> </td> <td> <b> $TotalNoAccessSite </b> </td> <td> <b> $TotalSites </b> </td> </tr> </table> " #========== $body += " <br> $report< </br>" $body += " <br> $report1 </br>" $attachment12="C:\Results_Active_Web.txt" toadd="" #$toadd= "" #$toadd="" #send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Attachments $attachment11 -Priority Low #Send-MailMessage -SmtpServer "smtp" -To $toadd -From "email address removed for privacy reasons" -Subject $subject -Body $body -BodyAsHtml #Send-MailMessage -SmtpServer "smtp" -To $toadd -From "email address removed for privacy reasons" -Subject $subject -Body $body -BodyAsHtml -Attachments $attachment12 -Priority Low Send-MailMessage -SmtpServer "smtp" -To $toadd -From "email address removed for privacy reasons" -Subject $subject -Body $body -BodyAsHtml -Priority Low #Send-MailMessage -SmtpServer "smtp" -To $toadd -From "email address removed for privacy reasons" -Subject $body -7Views0likes0CommentsHow to hide the Modify this view and Create View as per users available in groups
Hi All, I have classic view of SharePoint in list/libraries. I have group(for Managers). I just want want to show and hide the Create View/Modify View/Modify this view depends on users available in group. If user available in group(for Managers) then they can do anything like Create View/Modify View/Modify this view but if user is not a part of the group(for Managers) then they can not modify any Public views but the can create Personal view. Is there any way how I can achieve this functionality?30Views0likes0CommentsAutomating Microsoft 365 with PowerShell Second Edition
The Office 365 for IT Pros team are thrilled to announce the availability of Automating Microsoft 365 with PowerShell (2nd edition). This completely revised 350-page book delivers the most comprehensive coverage of how to use Microsoft Graph APIs and the Microsoft Graph PowerShell SDK with Microsoft 365 workloads (Entra ID, Exchange Online, SharePoint Online, Teams, Planner, and more). Existing subscribers can download the second edition now free of charge. https://office365itpros.com/2025/06/30/automating-microsoft-365-with-powershell2/794Views2likes10CommentsAdd-PublicFolderClientPermission: Object reference not set to an instance of an object.
Running into an issue with adding public folder permissions in Exchange Online. I've used this PowerShell script for a few years without any issues, but suddenly getting this error no matter what I try. I do have Owner permissions and there are Default and Anonymous permissions on the public folder, tried completely removing and reinstalling the ExchangeOnlineManagement module as well. Anyone else having this problem? $PF = Get-MailPublicFolder -Identity "\pf1" $User = Get-User -Anr "User1" $AccessRights = @( "ReadItems", "CreateItems", "EditOwnedItems", "EditAllItems", "FolderVisible" ) Add-PublicFolderClientPermission -Identity "\$($PF.Id)" -User $User.UserPrincipalName -AccessRights $AccessRights -Verbose VERBOSE: Returning precomputed version info: 3.9.2 VERBOSE: Requested HTTP/1.1 POST with 227-byte payload VERBOSE: Received HTTP/1.1 response of content type application/json of unknown size VERBOSE: Query 1 failed. Add-PublicFolderClientPermission: Object reference not set to an instance of an object. Thank you149Views0likes3CommentsGPU Partitioning in Windows Server 2025 Hyper-V
GPU Partitioning (GPU-P) is a feature in Windows Server 2025 Hyper-V that allows multiple virtual machines to share a single physical GPU by dividing it into isolated fractions. Each VM is allocated a dedicated portion of the GPU’s resources (memory, compute, encoders, etc.) instead of using the entire GPU. This is achieved via Single-Root I/O Virtualization (SR-IOV), which provides a hardware-enforced isolation between GPU partitions, ensuring each VM can access only its assigned GPU fraction with predictable performance and security. In contrast, GPU Passthrough (also known as Discrete Device Assignment, DDA) assigns a whole physical GPU exclusively to one VM. With DDA, the VM gets full control of the GPU, but no other VMs can use that GPU simultaneously. GPU-P’s ability to time-slice or partition the GPU allows higher utilization and VM density for graphics or compute workloads, whereas DDA offers maximum performance for a single VM at the cost of flexibility. GPU-P is ideal when you want to share a GPU among multiple VMs, such as for VDI desktops or AI inference tasks that only need a portion of a GPU’s power. DDA (passthrough) is preferred when a workload needs the full GPU (e.g. large model training) or when the GPU doesn’t support partitioning. Another major difference is mobility: GPU-P supports live VM mobility and failover clustering, meaning a VM using a GPU partition can move or restart on another host with minimal downtime. DDA-backed VMs cannot live-migrate. If you need to move a DDA VM, it must be powered off and then started on a target host (in clustering, a DDA VM will be restarted on a node with an available GPU upon failover, since live migration isn’t supported). Additionally, you cannot mix modes on the same device. A physical GPU can be either partitioned for GPU-P or passed through via DDA, but not both simultaneously. Supported GPU Hardware and Driver Requirements GPU Partitioning in Windows Server 2025 is supported on select GPU hardware that provides SR-IOV or similar virtualization capabilities, along with appropriate drivers. Only specific GPUs support GPU-P and you won’t be able to configure it on a consumer gaming GPU like your RTX 5090. In addition to the GPU itself, certain platform features are required: Modern CPU with IOMMU: The host processors must support Intel VT-d or AMD-Vi with DMA remapping (IOMMU). This is crucial for mapping device memory securely between host and VMs. Older processors lacking these enhancements may not fully support live migration of GPU partitions. BIOS Settings: Ensure that in each host’s UEFI/BIOS, Intel VT-d/AMD-Vi and SR-IOV are enabled. These options may be under virtualization or PCIe settings. Without SR-IOV enabled at the firmware level, the OS will not recognize the GPU as partitionable (in Windows Admin Center it might show status “Paravirtualization” indicating the driver is capable but the platform isn’t). Host GPU Drivers: Use vendor-provided drivers that support GPU virtualization. For NVIDIA, this means installing the NVIDIA virtual GPU (vGPU) driver on the Windows Server 2025 host (the driver package that supports GPU-P). Check the GPU vendor’s documentation for installation for specifics. After installing, you can verify the GPU’s status via PowerShell or WAC. Guest VM Drivers: The guest VMs also need appropriate GPU drivers installed (within the VM’s OS) to make use of the virtual GPU. For instance, if using Windows 11 or Windows Server 2025 as a guest, install the GPU driver inside the VM (often the same data-center driver or a guest-compatible subset from the vGPU package) so that the GPU is usable for DirectX/OpenGL or CUDA in that VM. Linux guests (Ubuntu 18.04/20.04/22.04 are supported) likewise need the Linux driver installed. Guest OS support for GPU-P in WS2025 covers Windows 10/11, Windows Server 2019+, and certain Ubuntu LTS versions. After hardware setup and driver installation, it’s important to verify that the host recognizes the GPU as “partitionable.” You can use Windows Admin Center or PowerShell for this: in WAC’s GPU tab, check the “Assigned status” of the GPU it should show “Partitioned” if everything is configured correctly (if it shows “Ready for DDA assignment” then the partitioning driver isn’t active, and if “Not assignable” then the GPU/driver doesn’t support either method). In PowerShell, you can run: Get-VMHostPartitionableGpu | FL Name, ValidPartitionCounts, PartitionCount This will list each GPU device’s identifier and what partition counts it supports. For example, an NVIDIA A40 might return ValidPartitionCounts : {16, 8, 4, 2 …} indicating the GPU can be split into 2, 4, 8, or 16 partitions, and also show the current PartitionCount setting (by default it may equal the max or current configured value). If no GPUs are listed, or the list is empty, the GPU is not recognized as partitionable (check drivers/BIOS). If the GPU is listed but ValidPartitionCounts is blank or shows only “1,” then it may not support SR-IOV and can only be used via DDA. Enabling and Configuring GPU Partitioning Once the hardware and drivers are ready, enabling GPU Partitioning involves configuring how the GPU will be divided and ensuring all Hyper-V hosts (especially in a cluster) have a consistent setup. Each physical GPU must be configured with a partition count (how many partitions to create on that GPU). You cannot define an arbitrary number – it must be one of the supported counts reported by the hardware/driver. The default might be the maximum supported (e.g., 16). To set a specific partition count, use PowerShell on each host: Decide on a partition count that suits your workloads. Fewer partitions means each VM gets more GPU resources (more VRAM and compute per partition), whereas more partitions means you can assign the GPU to more VMs concurrently (each getting a smaller slice). For AI/ML, you might choose a moderate number – e.g. split a 24 GB GPU into 4 partitions of ~6 GB each for inference tasks. Run the Set-VMHostPartitionableGpu cmdlet. Provide the GPU’s device ID (from the Name field of the earlier Get-VMHostPartitionableGpu output) and the desired -PartitionCount. For example: Set-VMHostPartitionableGpu -Name "<GPU-device-ID>" -PartitionCount 4 This would configure the GPU to be divided into 4 partitions. Repeat this for each GPU device if the host has multiple GPUs (or specify -Name accordingly for each). Verify the setting by running: Get-VMHostPartitionableGpu | FL Name,PartitionCount It should now show the PartitionCount set to your chosen value (e.g., PartitionCount : 4 for each listed GPU). If you are in a clustered environment, apply the same partition count on every host in the cluster for all identical GPUs. Consistency is critical: a VM using a “quarter GPU” partition can only fail over to another host that also has its GPU split into quarters. Windows Admin Center will actually enforce this by warning you if you try to set mismatched counts on different nodes. You can also configure the partition count via the WAC GUI. In WAC’s GPU partitions tool, select the GPU (or a set of homogeneous GPUs across hosts) and choose Configure partition count. WAC will present a dropdown of valid partition counts (as reported by the GPU). Selecting a number will show a tooltip of how much VRAM each partition would have (e.g., selecting 8 partitions on a 16 GB card might show ~2 GB per partition). WAC helps ensure you apply the change to all similar GPUs in the cluster together. After applying, it will update the partition count on each host automatically. After this step, the physical GPUs on the host (or cluster) are partitioned into the configured number of virtual GPUs. They are now ready to be assigned to VMs. The host’s perspective will show each partition as a shareable resource. (Note: You cannot assign more partitions to VMs than the number configured) Assigning GPU Partitions to Virtual Machines With the GPU partitioned at the host level, the next step is to attach a GPU partition to a VM. This is analogous to plugging a virtual GPU device into the VM. Each VM can have at most one GPU partition device attached, so choose the VM that needs GPU acceleration and assign one partition to it. There are two main ways to do this: using PowerShell commands or using the Windows Admin Center UI. Below are the instructions for each method. To add the GPU Partition to the VM use the Add-VMGpuPartitionAdapter cmdlet to attach a partitioned GPU to the VM. For example: Add-VMGpuPartitionAdapter -VMName "<VMName>" This will allocate one of the available GPU partitions on the host to the specified VM. (There is no parameter to specify which partition or GPU & Hyper-V will auto-select an available partition from a compatible GPU. If no partition is free or the host GPUs aren’t partitioned, this cmdlet will return an error) You can check that the VM has a GPU partition attached by running: Get-VMGpuPartitionAdapter -VMName "<VMName>" | FL InstancePath,PartitionId This will show details like the GPU device instance path and a PartitionId for the VM’s GPU device. If you see an entry with an instance path (matching the GPU’s PCI ID) and a PartitionId, the partition is successfully attached. Power on the VM. On boot, the VM’s OS will detect a new display adapter. In Windows guests, you should see a GPU in Device Manager (it may appear as a GPU with a specific model, or a virtual GPU device name). Install the appropriate GPU driver inside the VM if not already installed, so that the VM can fully utilize the GPU (for example, install NVIDIA drivers in the guest to get CUDA, DirectX, etc. working). Once the driver is active in the guest, the VM will be able to leverage the GPU partition for AI/ML computations or graphics rendering. Using Windows Admin Center: Open Windows Admin Center and navigate to your Hyper-V cluster or host, then go to the GPUs extension. Ensure you have added the GPUs extension v2.8.0 or later to WAC. In the GPU Partitions tab, you’ll see a list of the physical GPUs and any existing partitions. Click on “+ Assign partition”. This opens an assignment wizard. Select the VM: First choose the host server where the target VM currently resides (WAC will list all servers in the cluster). Then select the VM from that host to assign a partition to. (If a VM is greyed out in the list, it likely already has a GPU partition assigned or is incompatible.) Select Partition Size (VRAM): Choose the partition size from the dropdown. WAC will list options that correspond to the partition counts you configured. For example, if the GPU is split into 4, you might see an option like “25% of GPU (≈4 GB)” or similar. Ensure this matches the partition count you set. You cannot assign more memory than a partition contains. Offline Action (HA option): If the VM is clustered and you want it to be highly available, check the option for “Configure offline action to force shutdown” (if presented in the UI). Proceed to assign. WAC will automatically: shut down the VM (if it was running), attach a GPU partition to it, and then power the VM back on. After a brief moment, the VM should come online with the GPU partition attached. In the WAC GPU partitions list, you will now see an entry showing the VM name under the GPU partition it’s using. At this point, the VM is running with a virtual GPU. You can repeat the process for other VMs, up to the number of partitions available. Each physical GPU can only support a fixed number of active partitions equal to the PartitionCount set. If you attempt to assign more VMs than partitions, the additional VMs will not get a GPU (or the Add command will fail). Also note that a given VM can only occupy one partition on one GPU – you cannot span a single VM across multiple GPU partitions or across multiple GPUs with GPU-P. GPU Partitioning in Clustered Environments (Failover Clustering) One of the major benefits introduced with Windows Server 2025 is that GPU partitions can be used in Failover Clustering scenarios for high availability. This means you can have a Hyper-V cluster where VMs with virtual GPUs are clustered roles, capable of moving between hosts either through live migration (planned) or failover (unplanned). To utilize GPU-P in a cluster, you must pay special attention to configuration consistency and understand the current limitations: Use Windows Server 2025 Datacenter: As mentioned, clustering features (like failover) for GPU partitions are supported only on Datacenter edition. Homogeneous GPU Configuration: All hosts in the cluster should have identical GPU hardware and partitioning setup. Failover/Live Migration with GPU-P does not support mixing GPU models or partition sizes in a GPU-P cluster. Each host should have the same GPU model. The partition count configured (e.g., 4 or 8 etc.) must be the same on every host. This uniformity ensures that a VM expecting a certain size partition will find an equivalent on any other node. Windows Server 2025 introduces support for live migrating VMs that have a GPU partition attached. However, there are important caveats: Hardware support: Live migration with GPU-P requires that the hosts’ CPUs and chipsets fully support isolating DMA and device state. In practice, as noted, you need Intel VT-d or AMD-Vi enabled, and the CPUs ideally supporting “DMA bit tracking.” If this is in place, Hyper-V will attempt to live migrate the VM normally. During such a migration, the GPU’s state is not seamlessly copied like regular memory; instead, Windows will fallback to a slower migration process to preserve integrity. Specifically, when migrating a VM using GPU-P, Hyper-V automatically uses TCP/IP with compression (even if you have faster methods like RDMA configured). This is because device state transfer is more complex. The migration will still succeed, but you may notice higher CPU usage on the host and a longer migration time than usual. Cross-node compatibility: Ensure that the GPU driver versions on all hosts are the same, and that each host has an available partition for the VM. If a VM is running and you trigger a live migrate, Hyper-V will find a target where the VM can get an identical partition. If none are free, the migration will not proceed (or the VM may have to be restarted elsewhere as a failover). Failover (Unplanned Moves): If a host crashes or goes down, a clustered VM with a GPU partition will be automatically restarted on another node, much like any HA VM. The key difference is that the VM cannot save its state, so it will be a cold start on the new node, attaching to a new GPU partition there. When the VM comes up on the new node, it will request a GPU partition. Hyper-V will allocate one if available. If NodeB had no free partition (say all were assigned to other VMs), the VM might start but not get a GPU (and likely Windows would log an error that the virtual GPU could not start). Administrators should monitor and possibly leverage anti-affinity rules to avoid packing too many GPU VMs on one host if full automatic failover is required. To learn more about GPU-P on Windows Server 2025, consult the documentation on Learn: https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/gpu-partitioning4.4KViews1like3CommentsFile Type Version Limits
Hi all, In trying to solve an old issue I stumbled across this new feature currently in preview and am wondering if the file type arrays will be editable or if new arrays could be or will be added? I have a handful of file types which do not need 100 versions, let alone a version every 2-5 minutes, requiring frequent culling... Ling. https://learn.microsoft.com/en-us/sharepoint/file-type-version-limits112Views0likes2CommentsI built a free, open-source M365 security assessment tool - looking for feedback
I work as an IT consultant, and a good chunk of my time is spent assessing Microsoft 365 environments for small and mid-sized businesses. Every engagement started the same way: connect to five different PowerShell modules, run dozens of commands across Entra ID, Exchange Online, Defender, SharePoint, and Teams, manually compare each setting against CIS benchmarks, then spend hours assembling everything into a report the client could actually read. The tools that automate this either cost thousands per year, require standing up Azure infrastructure just to run, or only cover one service area. I wanted something simpler: one command that connects, assesses, and produces a client-ready deliverable. So I built it. What M365 Assess does https://github.com/Daren9m/M365-Assess is a PowerShell-based security assessment tool that runs against a Microsoft 365 tenant and produces a comprehensive set of reports. Here is what you get from a single run: 57 automated security checks aligned to the CIS Microsoft 365 Foundations Benchmark v6.0.1, covering Entra ID, Exchange Online, Defender for Office 365, SharePoint Online, and Teams 12 compliance frameworks mapped simultaneously -- every finding is cross-referenced against NIST 800-53, NIST CSF 2.0, ISO 27001:2022, SOC 2, HIPAA, PCI DSS v4.0.1, CMMC 2.0, CISA SCuBA, and DISA STIG (plus CIS profiles for E3 L1/L2 and E5 L1/L2) 20+ CSV exports covering users, mailboxes, MFA status, admin roles, conditional access policies, mail flow rules, device compliance, and more A self-contained HTML report with an executive summary, severity badges, sortable tables, and a compliance overview dashboard -- no external dependencies, fully base64-encoded, just open it in any browser or email it directly The entire assessment is read-only. It never modifies tenant settings. Only Get-* cmdlets are used. A few things I'm proud of Real-time progress in the console. As the assessment runs, you see each check complete with live status indicators and timing. No staring at a blank terminal wondering if it hung. The HTML report is a single file. Logos, backgrounds, fonts -- everything is embedded. You can email the report as an attachment and it renders perfectly. It supports dark mode (auto-detects system preference), and all tables are sortable by clicking column headers. Compliance framework mapping. This was the feature that took the most work. The compliance overview shows coverage percentages across all 12 frameworks, with drill-down to individual controls. Each finding links back to its CIS control ID and maps to every applicable framework control. Pass/Fail detail tables. Each security check shows the CIS control reference, what was checked, what the expected value is, what the actual value is, and a clear Pass/Fail/Warning status. Findings include remediation descriptions to help prioritize fixes. Quick start If you want to try it out, it takes about 5 minutes to get running: # Install prerequisites (if you don't have them already) Install-Module Microsoft.Graph, ExchangeOnlineManagement -Scope CurrentUser Clone and run git clone https://github.com/Daren9m/M365-Assess.git cd M365-Assess .\Invoke-M365Assessment.ps1 The interactive wizard walks you through selecting assessment sections, entering your tenant ID, and choosing an authentication method (interactive browser login, certificate-based, or pre-existing connections). Results land in a timestamped folder with all CSVs and the HTML report. Requires PowerShell 7.x and runs on Windows (macOS and Linux are experimental -- I would love help testing those platforms). Cloud support M365 Assess works with: Commercial (global) tenants GCC, GCC High, and DoD environments If you work in government cloud, the tool handles the different endpoint URIs automatically. What is next This is actively maintained and I have a roadmap of improvements: More automated checks -- 140 CIS v6.0.1 controls are tracked in the registry, with 57 automated today. Expanding coverage is the top priority. Remediation commands -- PowerShell snippets and portal steps for each finding, so you can fix issues directly from the report. XLSX compliance matrix -- A spreadsheet export for audit teams who need to work in Excel. Standalone report regeneration -- Re-run the report from existing CSV data without re-assessing the tenant. I would love your feedback I have been building this for my own consulting work, but I think it could be useful to the broader community. If you try it, I would genuinely appreciate hearing: What checks should I prioritize next? Which security controls matter most in your environment? What compliance frameworks are most requested by your clients or auditors? How does the report land with non-technical stakeholders? Is the executive summary useful, or does it need work? macOS/Linux users -- does it run? What breaks? I have tested it on macOS, but not extensively. Bug reports, feature requests, and contributions are all welcome on GitHub. Repository: https://github.com/Daren9m/M365-Assess License: MIT (free for commercial and personal use) Runtime: PowerShell 7.x Thanks for reading. Happy to answer any questions in the comments.322Views1like0CommentsHow to Remove Sensitivity Labels from SharePoint Files at Scale
It’s easy to remove sensitivity labels from SharePoint Online files when only a few files are involved. Doing the same task at scale requires automation. In this article, we explain how to use the Microsoft Graph PowerShell SDK to find and remove sensitivity labels from files stored in SharePoint Online and OneDrive for Business. https://office365itpros.com/2026/03/10/remove-sensitivity-labels-from-file/43Views0likes0CommentsPS script for moving clustered VMs to another node
Windows Server 2022, Hyper-V, Failover cluster We have a Hyper-V cluster where the hosts reboot once a month. If the host being rebooted has any number of VMs running on it the reboot can take hours. I've proven this by manually moving VM roles off of the host prior to reboot and the host reboots in less than an hour, usually around 15 minutes. Does anyone know of a powershell script that will detect clustered VMs running on the host and move them to another host within the cluster? I'd rather not reinvent this if someone's already done it.41Views0likes0Comments