'How do You Remove an Organization Segment With Linked User Groups in 365 Compliance Powershell?

I am trying to remove the organisation segments that I set up. When I run the command and pipe it into remove-organization segment or even if I remove it with the -identity argument, it throws the error below.

How do I remove the linked groups / users from the organization segement?

I can't seem to find an explanation on the MS documentation. I have marked the information barrier policies they are linked to as inactive and removed them.

Get-OrganizationSegment | Remove-OrganizationSegment

Your request failed to complete. Please retry. Error Details: System.InvalidOperationException,This information barrier segment ... can't be removed because it is being used

by both users and groups. Before you can remove this information barrier segment, make sure that neither users nor groups are linked to it.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source