Others

Fix Remove-UnifiedGroup Identity Errors in Exchange Online PowerShell

Camila MilosovichCamila Milosovich Nov 22, 2026 868 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Connect to Exchange Online

In PowerShell, run Connect-ExchangeOnline and sign in with an account that has permission to remove the groups.

2
Inspect the CSV column

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.

3
Preview the target groups

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.

4
Remove the verified groups

Run $groups | ForEach-Object { Remove-UnifiedGroup -Identity $_.GroupName -Confirm:$true } and review each confirmation prompt. Replace GroupName with the actual identifier column name.

Pass the CSV group identifier to Remove-UnifiedGroup
Use a property, not the whole row: Import-Csv produces an object for each row. Pass a specific property such as $_.GroupName or $_.GUID to -Identity, rather than passing $_ itself.
Free Microsoft Office alternative

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.

Open and review CSV columns containing group identifiersCompatible with Microsoft Excel XLSX filesFamiliar spreadsheet interface for an easy transition from OfficeFree and lightweight office suite
microsoft office alternative - wps office

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.