-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,381 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
function Get-GraphBookingsCustomQuestions { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$identity | ||
) | ||
$MBcustomQuestions = Get-MgBookingBusinessCustomQuestion -BookingBusinessId $identity | ||
$customQuestions = @() | ||
foreach ($customQuestion in $MBcustomQuestions) { | ||
$customQuestions += [PSCustomObject]@{ | ||
Id = $customQuestion.Id | ||
displayName = $customQuestion.DisplayName | ||
AnswerInputType = $customQuestion.AnswerInputType | ||
options = $customQuestion.AnswerOptions | ConvertTo-Json -Depth 10 | ||
createdDateTime = $customQuestion.AdditionalProperties["createdDateTime"] | ||
lastUpdatedDateTime = $customQuestion.AdditionalProperties["lastUpdatedDateTime"] | ||
} | ||
} | ||
return $customQuestions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
function SplitDomainFromEmail { | ||
param([string] $email) | ||
return [string]$email.Split("@")[1] | ||
} | ||
|
||
function IsConsumerMailbox { | ||
param([string]$identity) | ||
|
||
try { | ||
$consumerMb = Get-ConsumerMailbox $identity -ErrorAction Ignore | ||
return [boolean]$consumerMb.IsProsumerConsumerMailbox -or $consumerMb.IsMigratedConsumerMailbox -or $consumerMb.IsPremiumConsumerMailbox | ||
} catch { | ||
return $false #consumer mailbox throws error if domain mailbox | ||
} | ||
} | ||
|
||
function IsGetMailboxAvailable { | ||
if (Get-Command -Name Get-Mailbox -ErrorAction SilentlyContinue) { | ||
Write-Host "Validated connection to Exchange Online..." -ForegroundColor Green | ||
} else { | ||
Write-Error "Get-Mailbox cmdlet not found. Please validate that you are running this script from an Exchange Management Shell and try again." | ||
Write-Host "Look at Import-Module ExchangeOnlineManagement and Connect-ExchangeOnline." | ||
exit | ||
} | ||
} | ||
|
||
function WriteTestTitle { | ||
param([string]$title, [System.Boolean]$Success, [string]$errorMessage, [bool]$writeMessageAlways = $false) | ||
Write-Host ($title.PadRight($script:PadCharsMessage) + " : ") -NoNewline | ||
if ($Success) { | ||
if ($writeMessageAlways) { | ||
Write-GreenCheck | ||
Write-Host (" (" + $errorMessage + " )") -ForegroundColor Yellow | ||
} else { | ||
Write-GreenCheck -NewLine | ||
} | ||
} else { | ||
write-RedX | ||
Write-Host (" (" + $errorMessage + " )") -ForegroundColor Red | ||
} | ||
} | ||
|
||
function Write-GreenCheck { | ||
param ( | ||
[parameter()] | ||
[switch]$NewLine | ||
) | ||
$greenCheck = @{ | ||
Object = [Char]8730 | ||
ForegroundColor = 'Green' | ||
NoNewLine = if ($NewLine.IsPresent) { $false } else { $true } | ||
} | ||
Write-Host @greenCheck | ||
} | ||
|
||
function Write-RedX { | ||
param ( | ||
[parameter()] | ||
[switch]$NewLine | ||
) | ||
|
||
$redX = @{ | ||
Object = [Char]10060 | ||
ForegroundColor = 'Red' | ||
NoNewLine = if ($NewLine.IsPresent) { $false } else { $true } | ||
} | ||
Write-Host @redX | ||
} | ||
|
||
|
||
|
||
|
||
function Convert-ArrayToMultilineString { | ||
param ( | ||
[Array]$Array2D | ||
) | ||
|
||
# Initialize an empty string | ||
$outputString = "" | ||
|
||
# Loop through each row (key-value pair) of the array | ||
foreach ($pair in $Array2D) { | ||
# Ensure the array has exactly two elements (key and value) | ||
if ($pair.Count -eq 2) { | ||
# Append the key and value to the output string in "key: value" format | ||
$outputString += "$($pair[0]): $($pair[1])`n" | ||
} else { | ||
Write-Warning "Array row does not have exactly 2 elements: $pair" | ||
} | ||
} | ||
|
||
# Return the multi-line string | ||
return $outputString.TrimEnd("`n") | ||
} | ||
|
||
|
||
|
||
function CheckExcelModuleInstalled { | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
param () | ||
|
||
if (Get-Command -Module ImportExcel) { | ||
Write-Host "ImportExcel module is already installed." | ||
} else { | ||
# This is slow, to the tune of ~10 seconds, but much more complete. | ||
# Check if ImportExcel module is installed | ||
$moduleInstalled = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'ImportExcel' } | ||
|
||
if ($moduleInstalled) { | ||
Write-Host "ImportExcel module is already installed." | ||
} else { | ||
# Check if running with administrator rights | ||
$isAdministrator = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | ||
|
||
if (-not $isAdministrator) { | ||
Write-Host "Please run the script as an administrator to install the ImportExcel module." | ||
exit | ||
} | ||
|
||
# Ask user if they want to install the module | ||
if ($PSCmdlet.ShouldProcess('ImportExcel module', 'Import')) { | ||
Write-Verbose "Installing ImportExcel module..." | ||
|
||
# Install ImportExcel module | ||
Install-Module -Name ImportExcel -Force -AllowClobber | ||
|
||
Write-Host "Done. ImportExcel module is now installed. Please re-run the script." | ||
exit | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
function Get-BookingMBData { | ||
param ( | ||
[string]$Identity | ||
) | ||
|
||
$script:BMB = Get-Mailbox -Identity $Identity -ErrorAction SilentlyContinue | ||
if ($null -eq $script:BMB) { | ||
Write-DashLineBoxColor -Line "Booking Mailbox not found" -Color "Red" | ||
return $null | ||
} | ||
|
||
$bookingMBData = [PSCustomObject]@{ | ||
DisplayName = $script:BMB.DisplayName | ||
Identity = $script:BMB.Identity | ||
RecipientType = $script:BMB.RecipientType #: UserMailbox | ||
RecipientTypeDetails = $script:BMB.RecipientTypeDetails # SchedulingMailbox | ||
EmailAddresses = $script:BMB.EmailAddresses | ||
IsMailboxEnabled = $script:BMB.IsMailboxEnabled | ||
HiddenFromAddressListsEnabled = $script:BMB.HiddenFromAddressListsEnabled | ||
IsSoftDeletedByRemove = $script:BMB.IsSoftDeletedByRemove | ||
IsSoftDeletedByDisable = $script:BMB.IsSoftDeletedByDisable | ||
IsInactiveMailbox = $script:BMB.IsInactiveMailbox | ||
WhenSoftDeleted = $script:BMB.WhenSoftDeleted | ||
WindowsEmailAddress = $script:BMB.WindowsEmailAddress | ||
WhenCreated = $script:BMB.WhenCreated | ||
Guid = $script:BMB.Guid | ||
OriginatingServer = $script:BMB.OriginatingServer | ||
} | ||
return $bookingMBData | ||
} | ||
|
||
|
||
|
||
|
||
function Get-GraphBusiness { | ||
param ( | ||
[string]$Identity | ||
) | ||
|
||
$MB = Get-MgBookingBusiness -BookingBusinessId $Identity | ||
|
||
Write-Host "Exporting Working Hours" | ||
|
||
$a=$null | ||
$a=@() | ||
$a+= [PSCustomObject]@{ | ||
DisplayName = $MB.DisplayName | ||
OwnerEmail = $MB.Email | ||
IsPublished = $MB.IsPublished | ||
DefaultCurrencyIso = $MB.DefaultCurrencyIso | ||
DefaultTimeZone = $MB.DefaultTimeZone | ||
LanguageTag = $MB.LanguageTag | ||
Phone = $MB.Phone | ||
PublicUrl = $MB.PublicUrl | ||
WebSiteUrl = $MB.WebSiteUrl | ||
CreatedDateTime = $MB.AdditionalProperties["createdDateTime"] | ||
lastUpdatedDateTime = $MB.AdditionalProperties["lastUpdatedDateTime"] | ||
Address = "City= " + $MB.Address.City + ", `r`n" + | ||
"CountryOrRegion= " + $MB.Address.CountryOrRegion + ", `r`n" + | ||
"PostalCode= " + $MB.Address.PostalCode + ", `r`n" + | ||
"State= " + $MB.Address.State + ", `r`n" + | ||
"Street= " + $MB.Address.Street | ||
} | ||
|
||
return $a | ||
} | ||
|
||
|
||
function Get-GraphBusinessPage { | ||
param ( | ||
[string]$Identity | ||
) | ||
|
||
$MB = Get-MgBookingBusiness -BookingBusinessId $Identity | ||
|
||
Write-Host "Exporting Page Settings" | ||
|
||
$a=$null | ||
$a = @() | ||
foreach ( $pageSetting in $MB.AdditionalProperties.bookingPageSettings.Keys) { | ||
$a += [PSCustomObject]@{ | ||
Key = $pageSetting | ||
Value = $MB.AdditionalProperties.bookingPageSettings[$pageSetting] | ||
} | ||
} | ||
|
||
return $a | ||
} | ||
|
||
|
||
function Get-GraphBusinessBookingPolicy { | ||
param ( | ||
[string]$Identity | ||
) | ||
|
||
$MB = Get-MgBookingBusiness -BookingBusinessId $Identity | ||
|
||
Write-Host "Exporting Booking Policy" | ||
|
||
$a=$null | ||
$a = @() | ||
|
||
$a += [PSCustomObject]@{ | ||
Key = "AllowStaffSelection" | ||
Value = $MB.SchedulingPolicy.AllowStaffSelection | ||
} | ||
$a += [PSCustomObject]@{ | ||
Key = "MaximumAdvance" | ||
Value = "$($MB.SchedulingPolicy.MaximumAdvance.Days) days, $($MB.SchedulingPolicy.MaximumAdvance.Hours) hours and $($MB.SchedulingPolicy.MaximumAdvance.Minutes) minutes" | ||
} | ||
$a += [PSCustomObject]@{ | ||
Key = "MinimumLeadTime" | ||
Value = "$($MB.SchedulingPolicy.MinimumLeadTime.Days) days, $($MB.SchedulingPolicy.MinimumLeadTime.Hours) hours and $($MB.SchedulingPolicy.MinimumLeadTime.Minutes) minutes" | ||
} | ||
$a += [PSCustomObject]@{ | ||
Key = "SendConfirmationsToOwner" | ||
Value = $MB.SchedulingPolicy.SendConfirmationsToOwner | ||
} | ||
$a += [PSCustomObject]@{ | ||
Key = "TimeSlotInterval" | ||
Value = "$($MB.SchedulingPolicy.TimeSlotInterval.Hour) hours and $($MB.SchedulingPolicy.TimeSlotInterval.Minute) minutes" | ||
} | ||
$a += [PSCustomObject]@{ | ||
Key = "isMeetingInviteToCustomersEnabled" | ||
Value = $MB.SchedulingPolicy.AdditionalProperties["isMeetingInviteToCustomersEnabled"] | ||
} | ||
|
||
return $a | ||
} | ||
|
||
|
||
function Get-GraphBusinessWorkingHours { | ||
param ( | ||
[string]$Identity | ||
) | ||
|
||
$MB = Get-MgBookingBusiness -BookingBusinessId $Identity | ||
|
||
Write-Host "Exporting Working Hours" | ||
|
||
$a=$null | ||
$a = @() | ||
$a += [PSCustomObject]@{ | ||
Monday = "" | ||
Tuesday = "" | ||
Wednesday = "" | ||
Thursday = "" | ||
Friday = "" | ||
Saturday = "" | ||
Sunday = "" | ||
} | ||
#need to run iteractive loop so that I get a 2Dimensional data array at the end with the string values usable by Excel Export Module | ||
$max = 0 | ||
for ($i = 0; $i -le 7; $i++) { | ||
$max = [System.Math]::Max($max, $MB.BusinessHours[0].TimeSlots.Count ) | ||
} | ||
|
||
for ($i = 0; $i -le $max; $i++) { | ||
$monday = "" | ||
$tuesday = "" | ||
$wednesday = "" | ||
$thursday = "" | ||
$friday = "" | ||
$saturday = "" | ||
$sunday = "" | ||
|
||
if ($MB.BusinessHours[0].TimeSlots) { | ||
#ternary operator ? : only works on PS 7 | ||
#$monday = $i -ge $MB.BusinessHours[0].TimeSlots.Count ? "": $MB.BusinessHours[0].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[0].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[0].TimeSlots.Count) { | ||
$monday = "" | ||
} else { | ||
$monday = $MB.BusinessHours[0].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[0].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
|
||
} | ||
if ($MB.BusinessHours[1].TimeSlots) { | ||
#$tuesday = $i -ge $MB.BusinessHours[1].TimeSlots.Count ? "": $MB.BusinessHours[1].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[1].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[1].TimeSlots.Count) { | ||
$tuesday = "" | ||
} else { | ||
$tuesday = $MB.BusinessHours[1].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[1].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
if ($MB.BusinessHours[2].TimeSlots) { | ||
#$wednesday = $i -ge $MB.BusinessHours[2].TimeSlots.Count ? "": $MB.BusinessHours[2].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[2].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[2].TimeSlots.Count) { | ||
$wednesday = "" | ||
} else { | ||
$wednesday = $MB.BusinessHours[2].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[2].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
if ($MB.BusinessHours[3].TimeSlots) { | ||
#$thursday = $i -ge $MB.BusinessHours[3].TimeSlots.Count ? "": $MB.BusinessHours[3].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[3].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[3].TimeSlots.Count) { | ||
$thursday = "" | ||
} else { | ||
$thursday = $MB.BusinessHours[3].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[3].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
if ($MB.BusinessHours[4].TimeSlots) { | ||
#$friday = $i -ge $MB.BusinessHours[4].TimeSlots.Count ? "": $MB.BusinessHours[4].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[4].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[4].TimeSlots.Count) { | ||
$friday = "" | ||
} else { | ||
$friday = $MB.BusinessHours[4].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[4].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
if ($MB.BusinessHours[5].TimeSlots) { | ||
#$saturday = $i -ge $MB.BusinessHours[5].TimeSlots.Count ? "": $MB.BusinessHours[5].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[5].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[5].TimeSlots.Count) { | ||
$saturday = "" | ||
} else { | ||
$saturday = $MB.BusinessHours[5].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[5].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
if ($MB.BusinessHours[6].TimeSlots) { | ||
#$sunday = $i -ge $MB.BusinessHours[6].TimeSlots.Count ? "": $MB.BusinessHours[6].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[6].TimeSlots[$i].EndTime.Substring(0, 8) | ||
if ($i -ge $MB.BusinessHours[6].TimeSlots.Count) { | ||
$sunday = "" | ||
} else { | ||
$sunday = $MB.BusinessHours[6].TimeSlots[$i].StartTime.Substring(0, 8) + " to " + $MB.BusinessHours[6].TimeSlots[$i].EndTime.Substring(0, 8) | ||
} | ||
} | ||
|
||
$a += [PSCustomObject]@{ | ||
Monday = $monday | ||
Tuesday = $tuesday | ||
Wednesday = $wednesday | ||
Thursday = $thursday | ||
Friday = $friday | ||
Saturday = $saturday | ||
Sunday = $sunday | ||
} | ||
} | ||
|
||
return $a | ||
} |
Oops, something went wrong.