The New-MgBookingBusiness cmdlet in Microsoft Graph PowerShell is a powerful tool that allows administrators to create new bookings pages for businesses. Microsoft Bookings is an online scheduling tool that is integrated with Microsoft 365, enabling businesses to manage appointments and services. This cmdlet is particularly useful for automating the creation of business bookings pages in bulk, ensuring consistency and efficiency across multiple setups.
New-MgBookingBusiness -BodyParameter <IMicrosoftGraphBookingBusiness>
Creating a single business booking page is straightforward. The following example demonstrates how to create a new business booking page using the required properties:
$body = @{
DisplayName = "Contoso Health Clinic"
BusinessHours = @{
Day = "Monday"
StartTime = "08:00:00"
EndTime = "17:00:00"
}
Address = @{
Street = "123 Main St"
City = "Redmond"
State = "WA"
PostalCode = "98052"
CountryOrRegion = "US"
}
Phone = "+1 425-555-0100"
Email = "contact@contosohealthclinic.com"
WebSiteUrl = "https://contosohealthclinic.com"
}
New-MgBookingBusiness -BodyParameter $body
To create multiple business booking pages, you can loop through an array of hashtables, each representing a different business or service in your organization:
$businesses = @(
@{
DisplayName = "Contoso Health Clinic"
BusinessHours = @{
Day = "Monday"
StartTime = "08:00:00"
EndTime = "17:00:00"
}
Address = @{
Street = "123 Main St"
City = "Redmond"
State = "WA"
PostalCode = "98052"
CountryOrRegion = "US"
}
Phone = "+1 425-555-0100"
Email = "contact@contosohealthclinic.com"
WebSiteUrl = "https://contosohealthclinic.com"
}
@{
DisplayName = "Contoso Dental Clinic"
BusinessHours = @{
Day = "Tuesday"
StartTime = "09:00:00"
EndTime = "18:00:00"
}
Address = @{
Street = "456 Second St"
City = "Bellevue"
State = "WA"
PostalCode = "98007"
CountryOrRegion = "US"
}
Phone = "+1 425-555-0200"
Email = "contact@contosodentalclinic.com"
WebSiteUrl = "https://contosodentalclinic.com"
}
)
foreach ($business in $businesses) {
New-MgBookingBusiness -BodyParameter $business
}
For bulk creation of business booking pages, you can use a CSV file to import data and then create new business booking pages based on the data.
This is how the CSV file must be structured with the relevant headers:
DisplayName,Day,StartTime,EndTime,Street,City,State,PostalCode,CountryOrRegion,Phone,Email,WebSiteUrl
Contoso Health Clinic,Monday,08:00:00,17:00:00,123 Main St,Redmond,WA,98052,US,+1 425-555-0100,contact@contosohealthclinic.com,https://contosohealthclinic.com
Contoso Dental Clinic,Tuesday,09:00:00,18:00:00,456 Second St,Bellevue,WA,98007,US,+1 425-555-0200,contact@contosodentalclinic.com,https://contosodentalclinic.com
Contoso Spa,Wednesday,10:00:00,19:00:00,789 Third St,Kirkland,WA,98033,US,+1 425-555-0300,contact@contosospaclub.com,https://contosospaclub.com
$csv = Import-Csv -Path "C:\BookingBusinesses.csv"
foreach ($row in $csv) {
$body = @{
DisplayName = $row.DisplayName
BusinessHours = @{
Day = $row.Day
StartTime = $row.StartTime
EndTime = $row.EndTime
}
Address = @{
Street = $row.Street
City = $row.City
State = $row.State
PostalCode = $row.PostalCode
CountryOrRegion = $row.CountryOrRegion
}
Phone = $row.Phone
Email = $row.Email
WebSiteUrl = $row.WebSiteUrl
}
New-MgBookingBusiness -BodyParameter $body
}
Cause: This error occurs when a property in the -BodyParameter hashtable does not match the required format or is not recognized.
Solution: Double-check the property names and formats against the Microsoft documentation. Ensure that all required properties are included and correctly formatted.
Cause: This error generally occurs when the provided data does not meet the API requirements.
Solution: Validate all input data, especially fields like email addresses, URLs, and phone numbers. Ensure they follow the required formats.
Cause: This error occurs if the account used to run the cmdlet does not have the necessary permissions to create Booking businesses.
Solution: Ensure the account has the required permissions. You may need to delegate permissions or use a different account with the appropriate access. Bookings.Read or Bookings.ReadWrite.All is the required Graph API permission.
The New-MgBookingBusiness cmdlet is an essential tool for administrators managing Microsoft Bookings in Microsoft 365. Whether you're setting up a single Booking business or automating the creation of multiple businesses across different locations, this cmdlet provides the flexibility and power needed to streamline the process. By adhering to the conventions outlined in the Microsoft documentation and following best practices, you can avoid common pitfalls and effectively utilize this cmdlet in your day-to-day operations.
© m365corner.com. All Rights Reserved. Design by HTML Codex