Add -ResultSize Unlimited to all Get-Mailbox calls

This commit is contained in:
Jeremy D. Berkleef 2021-11-04 10:07:47 +01:00
parent 429240f403
commit 778dcd93cf

View File

@ -72,7 +72,7 @@ do
#Get the mailboxes from Exchange and print the email addresses to confirm the changes. #Get the mailboxes from Exchange and print the email addresses to confirm the changes.
Foreach ($Alias in $Alias_list) { Foreach ($Alias in $Alias_list) {
$addresses = (Get-Mailbox -Identity $Alias.Displayname).EmailAddresses $addresses = (Get-Mailbox -ResultSize Unlimited -Identity $Alias.Displayname).EmailAddresses
Write-Host -Foregroundcolor Red -Backgroundcolor White (Write-Output $Alias.Displayname); Write-Host -Foregroundcolor Red -Backgroundcolor White (Write-Output $Alias.Displayname);
write-Host -foregroundcolor Green -Separator `n (Write-Output $addresses) write-Host -foregroundcolor Green -Separator `n (Write-Output $addresses)
} }
@ -83,7 +83,7 @@ do
$CsvSavePath = Read-Host -Prompt 'Input location to save .csv' $CsvSavePath = Read-Host -Prompt 'Input location to save .csv'
#List Aliases and select #List Aliases and select
get-mailbox | Where-Object {$_.EmailAddresses -like "$searchTerm"} | Select-Object Displayname,@{Name="EmailAddresses";Expression={$_.EmailAddresses}} | Export-Csv -NoTypeInformation $CsvSavePath Get-Mailbox -ResultSize Unlimited | Where-Object {$_.EmailAddresses -like "$searchTerm"} | Select-Object Displayname,@{Name="EmailAddresses";Expression={$_.EmailAddresses}} | Export-Csv -NoTypeInformation $CsvSavePath
#Remind the user that they need to fix the csv formatting. #Remind the user that they need to fix the csv formatting.
Write-Host -ForegroundColor Red -BackgroundColor Black "Please be sure to remember to format the .csv correctly before importing it back into an Exchange Server or Exchange Online" Write-Host -ForegroundColor Red -BackgroundColor Black "Please be sure to remember to format the .csv correctly before importing it back into an Exchange Server or Exchange Online"
@ -95,7 +95,7 @@ do
$searchTerm = Read-Host -Prompt 'Input Query' $searchTerm = Read-Host -Prompt 'Input Query'
#List Aliases #List Aliases
get-mailbox | Where-Object {$_.EmailAddresses -like "$searchTerm"} |ForEach-Object{ Get-Mailbox -ResultSize Unlimited | Where-Object {$_.EmailAddresses -like "$searchTerm"} |ForEach-Object{
$host.UI.Write("White", $host.UI.RawUI.BackGroundColor, "`nUser Name: " + $_.DisplayName+"`n") $host.UI.Write("White", $host.UI.RawUI.BackGroundColor, "`nUser Name: " + $_.DisplayName+"`n")
@ -122,7 +122,7 @@ do
$searchTerm = Read-Host -Prompt "Search Query" $searchTerm = Read-Host -Prompt "Search Query"
Write-Host -ForegroundColor Blue -BackgroundColor White "Path must be in UNC format for Exchange to export to." Write-Host -ForegroundColor Blue -BackgroundColor White "Path must be in UNC format for Exchange to export to."
$savePath = Read-Host -Prompt "Export Path" $savePath = Read-Host -Prompt "Export Path"
$mailboxes = get-mailbox | Where-Object {$_.EmailAddresses -like "$searchTerm"} $mailboxes = Get-Mailbox -ResultSize Unlimited | Where-Object {$_.EmailAddresses -like "$searchTerm"}
Foreach ($mailbox in $mailboxes) { Foreach ($mailbox in $mailboxes) {
#Concatenate the save path and the mailbox alias. #Concatenate the save path and the mailbox alias.
@ -138,7 +138,7 @@ do
$targetDateFormat = Read-Host -Prompt "Date format to switch to (e.g. "d-M-yyy")" $targetDateFormat = Read-Host -Prompt "Date format to switch to (e.g. "d-M-yyy")"
#Search mailboxes and apply the changes #Search mailboxes and apply the changes
Get-Mailbox | Where-Object {$_.EmailAddresses -like "$searchTerm"} | Set-MailboxRegionalConfiguration -Language "$targetLanguage" -TimeZone "$targetTimezone" -DateFormat "$targetDateFormat" Get-Mailbox -ResultSize Unlimited | Where-Object {$_.EmailAddresses -like "$searchTerm"} | Set-MailboxRegionalConfiguration -Language "$targetLanguage" -TimeZone "$targetTimezone" -DateFormat "$targetDateFormat"
} }
} }