Docs | 聽
-- | --
Author | Laura Kokkarinen
Original Post | https://laurakokkarinen.com/does-it-spark-joy-powershell-scripts-for-keeping-your-development-environment-tidy-and-spotless/#delete-all-non-group-connected-modern-sharepoint-sites
Description | When you delete Office 365 groups, the modern group-connected team sites get deleted with them. The script below handles the remaining modern sites: communication sites and groupless team sites.
Keywords | SharePoint Online Office 365 Groups
@garrytrinder @waldekmastykarz ....wanted to clarify few queries.. Doing it for first time, so might be asking basic questions but better to clarify rather than assuming...appreciate your help..!
CC - @sprider - FYI.
@siddharth-vaghasia this issue is about creating a script sample, like https://github.com/pnp/office365-cli/blob/master/docs/manual/docs/examples/spo/remove-custom-themes.md. If the sample as described above by @garrytrinder requires a new command or updating an existing command, then we should create a separate issue for it. Hope this clarifies it a bit.
Welcome @siddharth-vaghasia 馃憢馃徏
Thank you for your questions, as @waldekmastykarz has mentioned, this issue is to produce a sample script for our documentation.
The idea behind the sample scripts are to take scripts built by others using PnP PowerShell and replicate the same functionality using CLI commands, in both PowerShell Core & Bash.
This approach helps us identify & document real world scenarios using the CLI, which we hope will help increase the usage of the CLI but also identify any potential gaps in functionality of our current commands.
If we can鈥檛 replicate the script due to missing functionality, then we can raise new issues to cover that and place this issue on hold until the missing functionality is implemented.
Thanks @waldekmastykarz and @garrytrinder .... Now I understood concept of sample script.... I was able to make same script work with CLI commands... also tested on my dev tenant....please check is this something we are looking for?
$sparksjoy = "Cat Lovers United", "Extranet", "Hub"
$sites = o365 spo site classic list -o json |ConvertFrom-Json
$sites = $sites | where { $_.template -eq "SITEPAGEPUBLISHING#0" -or $_.template -eq "STS#3" -and -not ($sparksjoy -contains $_.Title)}
if ($sites.Count -eq 0) { break }
$sites | Format-Table Title, Url, Template
Read-Host -Prompt "Press Enter to start deleting (CTRL + C to exit)"
$progress = 0
$total = $sites.Count
foreach ($site in $sites)
{
$progress++
write-host $progress / $total":" $site.Title
write-host $site.Url
o365 spo site classic remove --url $site.Url
}
I might have to make it work with bash....will check if we are okay with above...
Looking good @siddharth-vaghasia 馃憤馃徎
@garrytrinder ....do you have any suggestions for trying bash on windows machine? Unfortunately, I don't have linux setup.....
Git for Windows comes with git bash installed I believe, failing that you could try the new Windows Terminal
@garrytrinder ...got it, trying on git bash...!!
Please review and let me know if any changes are required..!