Fix Remove-UnifiedGroup Identity Errors in Exchange Online PowerShell
Question details
The user needs to delete Microsoft 365 groups listed in a CSV file without an Identity parameter conversion error.
- Product
- Exchange Online PowerShell
- Device & OS
- not provided
- Scenario
- A PowerShell script imports a CSV file and passes each row to Remove-UnifiedGroup.
- Observed behavior
- Passing the entire imported row as the Identity value causes a parameter conversion error because the cmdlet needs a group identifier.
Connect to Exchange Online PowerShell with an account authorized to remove the target groups. Check the CSV column names and verify the listed groups before proceeding; deleting a Microsoft 365 group can affect its associated resources.
Pass the CSV group identifier to Remove-UnifiedGroup
Use this method when each imported CSV row is being passed as an object instead of a group name, alias, or GUID.
In PowerShell, run Connect-ExchangeOnline and sign in with an account that has permission to remove the groups.
Run $groups = Import-Csv 'C:\path\groups.csv', then run $groups | Select-Object -First 1 | Format-List to inspect the column names and values. Identify the column containing each group name, alias, or GUID.
If the identifier column is named GroupName, run $groups | ForEach-Object { Get-UnifiedGroup -Identity $_.GroupName | Select-Object DisplayName, PrimarySmtpAddress } and verify the results. Replace GroupName with the actual CSV column name.
Run $groups | ForEach-Object { Remove-UnifiedGroup -Identity $_.GroupName -Confirm:$true } and review each confirmation prompt. Replace GroupName with the actual identifier column name.

Review group CSV files with WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility. Use WPS Spreadsheets to review CSV group lists alongside your existing Office files; removing groups still requires Exchange Online PowerShell.

Frequently Asked Questions
Why does Remove-UnifiedGroup -Identity $_ fail?
Import-Csv returns a row object, while -Identity expects a group identifier. Use a property such as $_.GroupName instead of the entire $_ object.
How do I find the correct CSV column name?
Run Import-Csv 'C:\path\groups.csv' | Select-Object -First 1 | Format-List in PowerShell. Use the displayed column name that contains the group identifier.
Can I use a GUID instead of a group name?
Yes. If the CSV has a GUID column containing group GUIDs, pass it with Remove-UnifiedGroup -Identity $_.GUID inside ForEach-Object.
How can I check which groups will be removed?
Before running Remove-UnifiedGroup, pipe the imported rows to Get-UnifiedGroup using the identifier property, then review the display names and primary SMTP addresses.




