Remove-MgBookingBusinessCustomer

What is Remove-MgBookingBusinessCustomer?

The Remove-MgBookingBusinessCustomer cmdlet is used to delete a specific customer record from a Microsoft Bookings business within Microsoft 365. When a customer’s information becomes outdated, or they no longer require your services, this cmdlet allows administrators to remove their data programmatically and maintain a clean customer directory.

🚀 Community Edition Released!

Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.

Why Use Remove-MgBookingBusinessCustomer?

Administrators use this cmdlet to:

  • Clean up obsolete customer records from Microsoft Bookings.
  • Automate customer data management tasks during offboarding or service termination.
  • Maintain an up-to-date and accurate customer list across departments and service branches.
  • Support bulk deletions using PowerShell loops or CSV-based scripts for large organizations.

Using PowerShell to remove customers ensures faster, more controlled, and repeatable data management for Bookings administrators.


Prerequisites

Before using this cmdlet, ensure you:

  1. Have installed the Microsoft Graph PowerShell module:
  2. Install-Module Microsoft.Graph -Scope CurrentUser
  3. Are connected to Microsoft Graph with the Bookings.ReadWrite.All permission scope:
  4. Connect-MgGraph -Scopes "Bookings.ReadWrite.All"

How to Use Remove-MgBookingBusinessCustomer?

To delete a customer from a Microsoft Bookings business, provide both the BookingBusinessId (the business identifier, typically its email address) and the BookingCustomerBaseId (the unique ID of the customer).

Remove-MgBookingBusinessCustomer -BookingBusinessId <String> -BookingCustomerBaseId <String>
                                            

Remove-MgBookingBusinessCustomer Examples

Example 1: Remove a Single Customer from a Booking Business

This example removes one customer from a specific Microsoft Bookings business.

$bookingBusinessId = "ContosoENTClinic@7xh7fj.onmicrosoft.com"
$customerId = "12345678-abcd-1234-efgh-56789abcdefg"
Remove-MgBookingBusinessCustomer -BookingBusinessId $bookingBusinessId -BookingCustomerBaseId $customerId
                                        

This command deletes the customer record associated with $customerId from the booking business identified by $bookingBusinessId.

Example 2: Remove Multiple Customers from a Booking Business

You can remove several customers by iterating through a list of customer IDs.

$bookingBusinessId = "ContosoENTClinic@7xh7fj.onmicrosoft.com"
$customerIds = @("12345678-abcd-1234-efgh-56789abcdefg", "22345678-abcd-2234-efgh-66789abcdefg")
foreach ($customerId in $customerIds) {
    Remove-MgBookingBusinessCustomer -BookingBusinessId $bookingBusinessId -BookingCustomerBaseId $customerId
}
                                        

This loop iterates through the $customerIds array and removes each customer from the specified booking business. It’s ideal for semi-bulk removal where you only need to remove a few specific customers.

Example 3: Bulk Removal of Customers Using a CSV File

For large-scale customer cleanup, you can use a CSV file containing all the customer IDs to remove.

CSV File Format:

CustomerId
12345678-abcd-1234-efgh-56789abcdefg
22345678-abcd-2234-efgh-66789abcdefg
32345678-abcd-3234-efgh-76789abcdefg
                                        

PowerShell Script:

$bookingBusinessId = "ContosoENTClinic@7xh7fj.onmicrosoft.com"
$csvPath = "C:\path\to\customers.csv"
$customers = Import-Csv -Path $csvPath

foreach ($customer in $customers) {
    Remove-MgBookingBusinessCustomer -BookingBusinessId $bookingBusinessId -BookingCustomerBaseId $customer.CustomerId
}
                                        

This script imports customer IDs from a CSV file and removes each corresponding record from the specified booking business. This method is particularly effective for tenant-wide cleanup tasks.


Summary

Key Point Details
Cmdlet Name Remove-MgBookingBusinessCustomer
Purpose Deletes a customer record from a Microsoft Bookings business
Required Scope Bookings.ReadWrite.All
Primary Parameters BookingBusinessId, BookingCustomerBaseId
Automation Benefit Enables streamlined deletion of customer data via automation
Use Case Ideal for offboarding, customer data cleanup, and bulk removals

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex