The New-MgBookingBusinessStaffMember cmdlet allows you to add staff members to a Microsoft Bookings business. This cmdlet is a powerful tool for managing the staff in your organization, enabling you to assign roles, set working hours, and decide whether or not to send email notifications to the staff members being added. In this article, we will explore the syntax, usage examples, tips, common errors, and practical use cases to make your implementation smoother.
New-MgBookingBusinessStaffMember -BusinessId -BodyParameter []
$staffMember = @{
displayName = "John Doe"
emailAddress = "john.doe@contoso.com"
role = "administrator"
isEmailNotificationEnabled = $false
workingHours = @(
@{
day = "monday"
timeSlots = @(
@{
startTime = "09:00:00"
endTime = "17:00:00"
}
)
}
@{
day = "wednesday"
timeSlots = @(
@{
startTime = "09:00:00"
endTime = "17:00:00"
}
)
}
@{
day = "friday"
timeSlots = @(
@{
startTime = "09:00:00"
endTime = "17:00:00"
}
)
}
)
}
New-MgBookingBusinessStaffMember -BusinessId "your-business-id" -BodyParameter $staffMember
This command adds a single staff member as an administrator with simple working hours and no email notifications.
$staffMembers = @(
@{
displayName = "Jane Smith"
emailAddress = "jane.smith@contoso.com"
role = "scheduler"
isEmailNotificationEnabled = $true
workingHours = @(
@{
day = "tuesday"
timeSlots = @(
@{
startTime = "10:00:00"
endTime = "18:00:00"
}
)
}
@{
day = "thursday"
timeSlots = @(
@{
startTime = "10:00:00"
endTime = "18:00:00"
}
)
}
)
}
@{
displayName = "Mark Taylor"
emailAddress = "mark.taylor@contoso.com"
role = "viewer"
isEmailNotificationEnabled = $false
workingHours = @(
@{
day = "monday"
timeSlots = @(
@{
startTime = "09:00:00"
endTime = "17:00:00"
}
)
}
@{
day = "wednesday"
timeSlots = @(
@{
startTime = "09:00:00"
endTime = "17:00:00"
}
)
}
)
}
)
New-MgBookingBusinessStaffMember -BusinessId "your-business-id" -BodyParameter $staffMembers
You can also add multiple staff members in a single command by passing an array of staff member objects.
For larger organizations, you might want to add staff members in bulk from a CSV file. Here’s how you can do it.
displayName,emailAddress,role,isEmailNotificationEnabled,workingHours
Alice Green,alice.green@contoso.com,guest,false,"monday:09:00-17:00,friday:09:00-17:00"
Bob Brown,bob.brown@contoso.com,administrator,true,"tuesday:08:00-16:00,thursday:08:00-16:00"
$csvData = Import-Csv -Path "C:\path\to\staffMembers.csv"
$staffMembers = @()
foreach ($row in $csvData) {
$workingHoursArray = @()
$workingHours = $row.workingHours -split ","
foreach ($slot in $workingHours) {
$day, $times = $slot -split ":"
$startTime, $endTime = $times -split "-"
$workingHoursArray += @{
day = $day
timeSlots = @(
@{
startTime = $startTime
endTime = $endTime
}
)
}
}
$staffMembers += @{
displayName = $row.displayName
emailAddress = $row.emailAddress
role = $row.role
isEmailNotificationEnabled = [bool]::Parse($row.isEmailNotificationEnabled)
workingHours = $workingHoursArray
}
}
New-MgBookingBusinessStaffMember -BusinessId "your-business-id" -BodyParameter $staffMembers
Cause: The role value provided does not match the acceptable values.
Solution: Ensure the role is one of the following: "administrator", "scheduler", "viewer", "guest".
Cause: The -BodyParameter hashtable is not properly formatted.
Solution: Double-check the structure of your hashtable, ensuring all properties follow the conventions laid out in the Microsoft documentation.
Cause: The time format in working hours is incorrect.
Solution: Use the 24-hour time format (e.g., "09:00:00" for 9 AM and "17:00:00" for 5 PM).
The New-MgBookingBusinessStaffMember cmdlet is a versatile tool for managing staff in Microsoft Bookings. By following the conventions for constructing the -BodyParameter, you can avoid common pitfalls and ensure your staff members are added smoothly. Whether you're adding a single staff member or importing them in bulk, this cmdlet provides the flexibility needed to efficiently manage your organization’s booking staff.
© m365corner.com. All Rights Reserved. Design by HTML Codex