
Hi @Vinod Survase ,
For your question:
1.To delete any SharePoint Online (SPO) site after a certain time automatically, you can create a custom site policy that automatically deletes sites that have been inactive for a specified period of time.
Once the site is close to the deletion date by means of the policy you set up above, you will constantly be reminded about that fact. First, if you log in to the site, you will see a notification message appearing on the top. Secondly, the site collection administrator will receive an email with a warning message.
For more detail steps,please refer to this article:https://sharepointmaven.com/how-to-set-site-closure-and-deletion-policies-in-sharepoint-online/
2.Identifying stale SPO sites that are associated with teams and non-teams can be done through the "Teams" and "Last activity (UTC)" parameters in the Sharepoint Admin center.
Or you can Get Unused Site Collections in the past 30 days using Pnp PowerShell:
$TenantAdminURL = "https://Crescent-Admin.SharePoint.com"
$TenantURL = "https://Crescent.SharePoint.com"
$DaysInActive = 30 # number of days to check since last modified
$CSVPath = "C:\Temp\InactiveSites.csv"
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude BOT, Video Portals and MySites
$SiteCollections = Get-PnPTenantSite -Filter "Url -like $TenantURL -and Url -notlike '-my.sharepoint.com/' -and Url -notlike '/portals/'"
#Calculate the Date
$Date = (Get-Date).AddDays(-$DaysInActive).ToString("MM/dd/yyyy")
#Get All Site collections where the content modified
$InActiveSites = $SiteCollections | Where {$_.LastContentModifiedDate -le $Date} | Select Title, Url, LastContentModifiedDate, Template, StorageMaximumLevel
#Export to CSV
$InActiveSites
$InActiveSites | Export-Csv -Path $CSVPath -NoTypeInformation
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.