Forum Discussion
Deleting Organization on SDS
- Oct 04, 2017
Hello.
Yes, you can.
Take a look at Bill Sluss's SDS Scripts here: https://github.com/OfficeDev/O365-EDU-Tools/tree/master/SDS%20Scripts
As schools are AdministrativeUnits (AUs) in Azure AD (AAD), you must use AAD's AU commands to do the job.
This script https://github.com/OfficeDev/O365-EDU-Tools/blob/master/SDS%20Scripts/Remove-All_Schools.ps1 has a perfect example, what steps are needed to gather the AUs. (I love the part, where those scripts actually check for and install if needed the required Powershell and MSOL Sign-In Assistant...)
Quick fix would be to comment the line 228 from:
Remove-MsolAdministrativeUnit -ObjectId $au.ObjectId -Force
to
#Remove-MsolAdministrativeUnit -ObjectId $au.ObjectId -Force
Just to be sure nothing can be deleted.
Now its perfectly safe to run the script in Powershell ISE, (set a breakpoint at line 227)
.\Remove-All_Schools.ps1 -RemoveSchoolAus $true
run to the point where it will ask you about deleting the schools really, here you can answer yes (as we disabled the actual delete-functionality with the # in front of line 228), let the program run until breakpoint at line 227 and then examine the resulting csv file made. (name and path are on-screen)
It will contain the needed ObjectIDs for the school AUs.
With that info you can actually delete the AU you want like this:
Remove-MsolAdministrativeUnit -ObjectId 1dc48982-fdac-4bd5-b21a-d8997ed11111 -Force
Then check the school is deleted.
PS. Kudos to
Written by: SDS Team, and adapted by Bill Sluss Regards
Marko
Hello.
Yes, you can.
Take a look at Bill Sluss's SDS Scripts here: https://github.com/OfficeDev/O365-EDU-Tools/tree/master/SDS%20Scripts
As schools are AdministrativeUnits (AUs) in Azure AD (AAD), you must use AAD's AU commands to do the job.
This script https://github.com/OfficeDev/O365-EDU-Tools/blob/master/SDS%20Scripts/Remove-All_Schools.ps1 has a perfect example, what steps are needed to gather the AUs. (I love the part, where those scripts actually check for and install if needed the required Powershell and MSOL Sign-In Assistant...)
Quick fix would be to comment the line 228 from:
Remove-MsolAdministrativeUnit -ObjectId $au.ObjectId -Force
to
#Remove-MsolAdministrativeUnit -ObjectId $au.ObjectId -Force
Just to be sure nothing can be deleted.
Now its perfectly safe to run the script in Powershell ISE, (set a breakpoint at line 227)
.\Remove-All_Schools.ps1 -RemoveSchoolAus $true
run to the point where it will ask you about deleting the schools really, here you can answer yes (as we disabled the actual delete-functionality with the # in front of line 228), let the program run until breakpoint at line 227 and then examine the resulting csv file made. (name and path are on-screen)
It will contain the needed ObjectIDs for the school AUs.
With that info you can actually delete the AU you want like this:
Remove-MsolAdministrativeUnit -ObjectId 1dc48982-fdac-4bd5-b21a-d8997ed11111 -Force
Then check the school is deleted.
PS. Kudos to
Written by: SDS Team, and adapted by Bill Sluss |
Regards
Marko
- jmThiaAug 27, 2018Brass Contributor
Hello,
Will remove-MsolAdministrative unit also remove all data from the school ?
Well I have synced the csv sample files in my tenant and want to make some cleanup.
Thanks,
Jean Marie
- Marko FrankenAug 27, 2018Brass Contributor
Hi.
Maybe from the School AU, yes, as it is deleted. But person objects involved will have the SDS attributes still in place, not a problem, as those will be recycled if resynced with SDS, otherwise those are somewhat deep under, not really hidden, but not advertised, and not visible to other users.
You have to try and see...
MF