35 C
Dubai
Saturday, May 3, 2025
Home Blog Page 32

Database availability group must have quorum error

Decommissioning set of old Exchange 2013 servers had to export few mailboxes and
decommission them.But mailboxes are not mounting saying quorum not found. but for me the simplest way is to remove the Database Availability group completely and mount the databases and take the required data out via pst and decommission the same. So this might not be suitable for all scenarios.

Failed to mount database "MDB03". Error: An Active Manager operation failed. Error: An Active Manager operation
encountered an error. To perform this operation, the server must be a member of a database availability group, and the
database availability group must have quorum. Error: Unable to read from the cluster database. This may occur if the
server has recently been removed from the database availability group. [Server: MBEX01.azure365pro.com]
+ CategoryInfo : InvalidOperation: (MDB03:ADObjectId) [Mount-Database], InvalidOperationException
+ FullyQualifiedErrorId : [Server=MBEX02,RequestId=c41e871c-49e5-4a78-877f-51738b965ee1,TimeStamp=6/2/2020
6:11:51 AM] [FailureCategory=Cmdlet-InvalidOperationException] 7E29F70A,Microsoft.Exchange.Management.SystemConfig
urationTasks.MountDatabase
+ PSComputerName : mbex02.azure365pro.com

Removed all the Database Copies.

Using the configuration only switch and removed the mailbox servers from the DAG.
So that it will clear the DAG related entries from active directory.But this will not remove the dag member from real Cluster. Which we have to manually.

Remove-DatabaseAvailabilityGroupServer -ConfigurationOnly -MailboxServer SRV-HO-MBEX02 -Identity DAG2

As its a IP Less DAG,We cannot use the cluster manager to evice them. You got to use powershell.
To Evict the DAG Members.

Get-ClusterNode Node1 | Remove-ClusterNode -Force
Get-ClusterNode Node2 | Remove-ClusterNode -Force

Once the DAG Members are removed and it doesn’t have configuration on active directory. Now the databases will try to mount as a stand alone server.On reboot Databases mounted without DAG membership.

Now removed the DAG. using below commands. I have done the same steps when the cluster is completely messed up and none of the recovery options worked and we had to bring up the databases stand alone without DAG membership. Unless you understand the environment completely and don’t use this procedure without proper understanding of clusters and DAG attributes stored on Active Directory. It may cause real Damage to the environment.

.\MailboxSizeReport.ps1 for Exchange and Office 365

Script Supports – Exchange 2007, 2010, 2013 , 2016 & Office 365

.\MailboxSizeReport.ps1 Created a Mailbox Size Report for Exchange 2010 and Exchange 2013.

It can Generate CSV, Display all and Display with Wild Card.

Download the Script

clip_image001

Download the Script

It can collect below information in CSV

  • Display Name
  • Alias
  • SamAccountname
  • RecipientType
  • Recipient OU
  • Primary SMTP address
  • Email Addresses
  • Database
  • ServerName
  • TotalItemSize
  • ItemCount
  • DeletedItemCount
  • TotalDeletedItemSize
  • ProhibitSendReceiveQuota-In-MB
  • UseDatabaseQuotaDefaults
  • LastLogonTime
  • ArchiveName
  • ArchiveStatus
  • ArchiveQuota
  • ArchiveTotalItemSize
  • ArchiveTotalItemCount

Note: If the LastLogonTime and stats empty. User hasn’t logged on yet.

Please feel free to add comments for additions or customizations.

For Office 365 Admins –

Connect to Office 365 Power shell – Before running the script

https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx

</pre>
<#
 
.Requires -version 2 - Runs in Exchange Management Shell or Open Powershell and Connect to Office365
 
.SYNOPSIS
.\MailboxSizeReport.ps1 - It Can Display all the Mailbox Size with Item Count,Database,Server Details
 
Or It can Export to a CSV file
 
Or You can Enter WildCard to Display or Export
 
Example 1
 
[PS] C:\>.\MailboxSizeReport.ps1
 
Mailbox Size Report
----------------------------
 
1.Display in Exchange Management Shell
 
2.Export to CSV File
 
3.Enter the Mailbox Name with Wild Card (Export)
 
4.Enter the Mailbox Name with Wild Card (Display)
 
5.Export to CSV File (OFFICE 365)
 
6.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)
 
Choose The Task: 1
 
Display Name Primary SMTP address TotalItemSize ItemCount
------------ -------------------- ------------- ---------
Tes433 Tes433@localhost
Test Test@localhost 335.9 KB (343,933 bytes) 40
Test X500 TestX500@localhost 6.544 KB (6,701 bytes) 3
Test100 test100@localhost 40.74 KB (41,719 bytes) 7
Test22 Test22@localhost 60.04 KB (61,483 bytes) 7
Test3 Test3@localhost 364.7 KB (373,503 bytes) 31
Test33 Test332@localhost 93.34 KB (95,585 bytes) 6
Test33 Test33@FSD.com 5.335 KB (5,463 bytes) 3
Test3331 Test3331@localhost 24.14 KB (24,720 bytes) 2
Test46 Test46@localhost 254 KB (260,071 bytes) 21
 
Example 2
 
[PS] C:\>.\MailboxSizeReport.ps1
 
Mailbox Size Report
----------------------------
 
1.Display in Exchange Management Shell
 
2.Export to CSV File
 
3.Enter the Mailbox Name with Wild Card (Export)
 
4.Enter the Mailbox Name with Wild Card (Display)
 
5.Export to CSV File (OFFICE 365)
 
6.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)
 
Choose The Task: 2
Enter the Path of CSV file (Eg. C:\Report.csv): C:\MailboxReport.csv
 
.Author
Written By: Satheshwaran Manoharan
 
Change Log
V1.0, 10/08/2014 - Initial version
 
Change Log
V1.1, 05/12/2016 - ProgressBar,Seperate Office 365 Options, QuotaLimits,EmailAddresses
 
Change Log
V1.2, 20/06/2019 - ArchiveName,ArchiveStatus,ArchiveState,ArchiveQuota,-Encoding UTF8,Bugfix -DB Quota,Bug fix Single object listing-DividebyZero
 
#>
 
Write-host "
 
Mailbox Size Report
----------------------------
 
1.Display in Exchange Management Shell
 
2.Export to CSV File
 
3.Export to CSV File (Specific to Database)
 
4.Enter the Mailbox Name with Wild Card (Export)
 
5.Enter the Mailbox Name with Wild Card (Display)
 
6.Export to CSV File (OFFICE 365)
 
7.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)"-ForeGround "Cyan"
 
#----------------
# Script
#----------------
 
Write-Host " "
 
$number = Read-Host "Choose The Task"
$output = @()
switch ($number)
{
 
1 {
 
$AllMailbox = Get-mailbox -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
 
Write-Output $Userobj
 
}
 
;Break}
 
2 {
$i = 0
 
$CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\Report.csv)"
 
$AllMailbox = Get-mailbox -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -eq $null)
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -ne $null)
{
$ProhibitSendReceiveQuota = (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.Value.ToMB()
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -eq $null))
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -ne $null))
{
$ProhibitSendReceiveQuota = $Mbx.ProhibitSendReceiveQuota.Value.ToMB()
}
if ($Mbx.ArchiveName.count -eq "0")
{
$ArchiveTotalItemSize = $null
$ArchiveTotalItemCount = $null
}
if ($Mbx.ArchiveName -ge "1")
{
$MbxArchiveStats = Get-mailboxstatistics $Mbx.distinguishedname -Archive -WarningAction SilentlyContinue
$ArchiveTotalItemSize = $MbxArchiveStats.TotalItemSize
$ArchiveTotalItemCount = $MbxArchiveStats.BigFunnelMessageCount
}
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias
$userObj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mbx.SamAccountName
$userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientTypeDetails
$userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "Email Addresses" -Value ($Mbx.EmailAddresses.smtpaddress -join ";")
$userObj | Add-Member NoteProperty -Name "Database" -Value $mbx.Database
$userObj | Add-Member NoteProperty -Name "ServerName" -Value $mbx.ServerName
if($Stats)
{
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize.Value.ToMB()
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
$userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount
$userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize.Value.ToMB()
}
$userObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota-In-MB" -Value $ProhibitSendReceiveQuota
$userObj | Add-Member NoteProperty -Name "UseDatabaseQuotaDefaults" -Value $Mbx.UseDatabaseQuotaDefaults
$userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime
$userObj | Add-Member NoteProperty -Name "ArchiveName" -Value ($Mbx.ArchiveName -join ";")
$userObj | Add-Member NoteProperty -Name "ArchiveStatus" -Value $Mbx.ArchiveStatus
$userObj | Add-Member NoteProperty -Name "ArchiveState" -Value $Mbx.ArchiveState
$userObj | Add-Member NoteProperty -Name "ArchiveQuota" -Value $Mbx.ArchiveQuota
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemSize" -Value $ArchiveTotalItemSize
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemCount" -Value $ArchiveTotalItemCount
 
$output += $UserObj
# Update Counters and Write Progress
$i++
if ($AllMailbox.Count -ge 1)
{
Write-Progress -Activity "Scanning Mailboxes . . ." -Status "Scanned: $i of $($AllMailbox.Count)" -PercentComplete ($i/$AllMailbox.Count*100)
}
}
 
$output | Export-csv -Path $CSVfile -NoTypeInformation -Encoding UTF8
 
;Break}
 
3 {
$i = 0
 
$CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\Report.csv)"
$Database = Read-Host "Enter the DatabaseName (Eg. Database 01)"
 
$AllMailbox = Get-mailbox -resultsize unlimited -Database "$Database"
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -eq $null)
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -ne $null)
{
$ProhibitSendReceiveQuota = (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.Value.ToMB()
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -eq $null))
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -ne $null))
{
$ProhibitSendReceiveQuota = $Mbx.ProhibitSendReceiveQuota.Value.ToMB()
}
if ($Mbx.ArchiveName.count -eq "0")
{
$ArchiveTotalItemSize = $null
$ArchiveTotalItemCount = $null
}
if ($Mbx.ArchiveName -ge "1")
{
$MbxArchiveStats = Get-mailboxstatistics $Mbx.distinguishedname -Archive -WarningAction SilentlyContinue
$ArchiveTotalItemSize = $MbxArchiveStats.TotalItemSize
$ArchiveTotalItemCount = $MbxArchiveStats.BigFunnelMessageCount
}
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias
$userObj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mbx.SamAccountName
$userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientTypeDetails
$userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "Email Addresses" -Value ($Mbx.EmailAddresses.smtpaddress -join ";")
$userObj | Add-Member NoteProperty -Name "Database" -Value $mbx.Database
$userObj | Add-Member NoteProperty -Name "ServerName" -Value $mbx.ServerName
if($Stats)
{
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize.Value.ToMB()
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
$userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount
$userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize.Value.ToMB()
}
$userObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota-In-MB" -Value $ProhibitSendReceiveQuota
$userObj | Add-Member NoteProperty -Name "UseDatabaseQuotaDefaults" -Value $Mbx.UseDatabaseQuotaDefaults
$userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime
$userObj | Add-Member NoteProperty -Name "ArchiveName" -Value ($Mbx.ArchiveName -join ";")
$userObj | Add-Member NoteProperty -Name "ArchiveStatus" -Value $Mbx.ArchiveStatus
$userObj | Add-Member NoteProperty -Name "ArchiveState" -Value $Mbx.ArchiveState
$userObj | Add-Member NoteProperty -Name "ArchiveQuota" -Value $Mbx.ArchiveQuota
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemSize" -Value $ArchiveTotalItemSize
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemCount" -Value $ArchiveTotalItemCount
 
$output += $UserObj
# Update Counters and Write Progress
$i++
if ($AllMailbox.Count -ge 1)
{
Write-Progress -Activity "Scanning Mailboxes . . ." -Status "Scanned: $i of $($AllMailbox.Count)" -PercentComplete ($i/$AllMailbox.Count*100)
}
}
 
$output | Export-csv -Path $CSVfile -NoTypeInformation -Encoding UTF8
 
;Break}
 
4 {
$i = 0
$CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\DG.csv)"
 
$MailboxName = Read-Host "Enter the Mailbox name or Range (Eg. Mailboxname , Mi*,*Mik)"
 
$AllMailbox = Get-mailbox $MailboxName -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -eq $null)
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $true) -and (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.value -ne $null)
{
$ProhibitSendReceiveQuota = (Get-MailboxDatabase $mbx.Database).ProhibitSendReceiveQuota.Value.ToMB()
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -eq $null))
{
$ProhibitSendReceiveQuota = "Unlimited"
}
if (($Mbx.UseDatabaseQuotaDefaults -eq $false) -and ($mbx.ProhibitSendReceiveQuota.value -ne $null))
{
$ProhibitSendReceiveQuota = $Mbx.ProhibitSendReceiveQuota.Value.ToMB()
}
if ($Mbx.ArchiveName.count -eq "0")
{
$ArchiveTotalItemSize = $null
$ArchiveTotalItemCount = $null
}
if ($Mbx.ArchiveName -ge "1")
{
$MbxArchiveStats = Get-mailboxstatistics $Mbx.distinguishedname -Archive -WarningAction SilentlyContinue
$ArchiveTotalItemSize = $MbxArchiveStats.TotalItemSize
$ArchiveTotalItemCount = $MbxArchiveStats.BigFunnelMessageCount
}
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias
$userObj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mbx.SamAccountName
$userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientTypeDetails
$userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "Email Addresses" -Value ($Mbx.EmailAddresses.smtpaddress -join ";")
$userObj | Add-Member NoteProperty -Name "Database" -Value $mbx.Database
$userObj | Add-Member NoteProperty -Name "ServerName" -Value $mbx.ServerName
if($Stats)
{
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize.Value.ToMB()
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
$userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount
$userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize.Value.ToMB()
}
$userObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota-In-MB" -Value $ProhibitSendReceiveQuota
$userObj | Add-Member NoteProperty -Name "UseDatabaseQuotaDefaults" -Value $Mbx.UseDatabaseQuotaDefaults
$userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime
$userObj | Add-Member NoteProperty -Name "ArchiveName" -Value ($Mbx.ArchiveName -join ";")
$userObj | Add-Member NoteProperty -Name "ArchiveStatus" -Value $Mbx.ArchiveStatus
$userObj | Add-Member NoteProperty -Name "ArchiveState" -Value $Mbx.ArchiveState
$userObj | Add-Member NoteProperty -Name "ArchiveQuota" -Value $Mbx.ArchiveQuota
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemSize" -Value $ArchiveTotalItemSize
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemCount" -Value $ArchiveTotalItemCount
 
$output += $UserObj
# Update Counters and Write Progress
$i++
if ($AllMailbox.Count -ge 1)
{
Write-Progress -Activity "Scanning Mailboxes . . ." -Status "Scanned: $i of $($AllMailbox.Count)" -PercentComplete ($i/$AllMailbox.Count*100)
}
}
 
$output | Export-csv -Path $CSVfile -NoTypeInformation -Encoding UTF8
 
;Break}
 
5 {
 
$MailboxName = Read-Host "Enter the Mailbox name or Range (Eg. Mailboxname , Mi*,*Mik)"
 
$AllMailbox = Get-mailbox $MailboxName -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
 
Write-Output $Userobj
 
}
 
;Break}
 
6 {
$i = 0
$CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\Report.csv)"
 
$AllMailbox = Get-mailbox -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
if ($Mbx.ArchiveName.count -eq "0")
{
$ArchiveTotalItemSize = $null
$ArchiveTotalItemCount = $null
}
if ($Mbx.ArchiveName -ge "1")
{
$MbxArchiveStats = Get-mailboxstatistics $Mbx.distinguishedname -Archive -WarningAction SilentlyContinue
$ArchiveTotalItemSize = $MbxArchiveStats.TotalItemSize
$ArchiveTotalItemCount = $MbxArchiveStats.BigFunnelMessageCount
}
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias
$userObj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mbx.SamAccountName
$userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientTypeDetails
$userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "Email Addresses" -Value ($Mbx.EmailAddresses -join ";")
$userObj | Add-Member NoteProperty -Name "Database" -Value $Stats.Database
$userObj | Add-Member NoteProperty -Name "ServerName" -Value $Stats.ServerName
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
$userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount
$userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize
$userObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota-In-MB" -Value $Mbx.ProhibitSendReceiveQuota
$userObj | Add-Member NoteProperty -Name "UseDatabaseQuotaDefaults" -Value $Mbx.UseDatabaseQuotaDefaults
$userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime
$userObj | Add-Member NoteProperty -Name "ArchiveName" -Value ($Mbx.ArchiveName -join ";")
$userObj | Add-Member NoteProperty -Name "ArchiveStatus" -Value $Mbx.ArchiveStatus
$userObj | Add-Member NoteProperty -Name "ArchiveState" -Value $Mbx.ArchiveState
$userObj | Add-Member NoteProperty -Name "ArchiveQuota" -Value $Mbx.ArchiveQuota
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemSize" -Value $ArchiveTotalItemSize
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemCount" -Value $ArchiveTotalItemCount
 
$output += $UserObj
# Update Counters and Write Progress
$i++
if ($AllMailbox.Count -ge 1)
{
Write-Progress -Activity "Scanning Mailboxes . . ." -Status "Scanned: $i of $($AllMailbox.Count)" -PercentComplete ($i/$AllMailbox.Count*100)
}
}
 
$output | Export-csv -Path $CSVfile -NoTypeInformation -Encoding UTF8
 
;Break}
 
7 {
$i = 0
$CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\DG.csv)"
 
$MailboxName = Read-Host "Enter the Mailbox name or Range (Eg. Mailboxname , Mi*,*Mik)"
 
$AllMailbox = Get-mailbox $MailboxName -resultsize unlimited
 
Foreach($Mbx in $AllMailbox)
 
{
 
$Stats = Get-mailboxStatistics -Identity $Mbx.distinguishedname -WarningAction SilentlyContinue
 
if ($Mbx.ArchiveName.count -eq "0")
{
$ArchiveTotalItemSize = $null
$ArchiveTotalItemCount = $null
}
if ($Mbx.ArchiveName -ge "1")
{
$MbxArchiveStats = Get-mailboxstatistics $Mbx.distinguishedname -Archive -WarningAction SilentlyContinue
$ArchiveTotalItemSize = $MbxArchiveStats.TotalItemSize
$ArchiveTotalItemCount = $MbxArchiveStats.BigFunnelMessageCount
}
 
$userObj = New-Object PSObject
 
$userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname
$userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias
$userObj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mbx.SamAccountName
$userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientTypeDetails
$userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit
$userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress
$userObj | Add-Member NoteProperty -Name "Email Addresses" -Value ($Mbx.EmailAddresses -join ";")
$userObj | Add-Member NoteProperty -Name "Database" -Value $Stats.Database
$userObj | Add-Member NoteProperty -Name "ServerName" -Value $Stats.ServerName
$userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize
$userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount
$userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount
$userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize
$userObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota-In-MB" -Value $Mbx.ProhibitSendReceiveQuota
$userObj | Add-Member NoteProperty -Name "UseDatabaseQuotaDefaults" -Value $Mbx.UseDatabaseQuotaDefaults
$userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime
$userObj | Add-Member NoteProperty -Name "ArchiveName" -Value ($Mbx.ArchiveName -join ";")
$userObj | Add-Member NoteProperty -Name "ArchiveStatus" -Value $Mbx.ArchiveStatus
$userObj | Add-Member NoteProperty -Name "ArchiveState" -Value $Mbx.ArchiveState
$userObj | Add-Member NoteProperty -Name "ArchiveQuota" -Value $Mbx.ArchiveQuota
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemSize" -Value $ArchiveTotalItemSize
$userObj | Add-Member NoteProperty -Name "ArchiveTotalItemCount" -Value $ArchiveTotalItemCount
 
$output += $UserObj
# Update Counters and Write Progress
$i++
if ($AllMailbox.Count -ge 1)
{
Write-Progress -Activity "Scanning Mailboxes . . ." -Status "Scanned: $i of $($AllMailbox.Count)" -PercentComplete ($i/$AllMailbox.Count*100) -ErrorAction SilentlyContinue
}
}
 
$output | Export-csv -Path $CSVfile -NoTypeInformation -Encoding UTF8
 
;Break}
 
Default {Write-Host "No matches found , Enter Options 1 or 2" -ForeGround "red"}
 
}
<pre>

Rename Office 365 Unified Groups

Renaming Office 365 Unified Groups and updating group email address or domain is not via GUI at this point of time. we need to use powershell to update the same.

Connect-EXOPSSession

 

Run below to get the required groupID

Get-UnifiedGroup

Once you get the required group ID , Use below to check the email address

Get-UnifiedGroup -Identity "InformationTechnology_50e33be9-0000-43e4-8dc4-000044ab1a4" | FL EmailAddresses

Run the below command to add SMTP alias which will be the primary address or you can leave it as alias whichever is your requirement.

Set-UnifiedGroup -Identity "InformationTechnology_50e33be9-0000-43e4-8dc4-000044ab1a4" -EmailAddresses: @{Add ="InformationTechnology@localhost"}

Set the added additional alias as primary addresss

Set-UnifiedGroup -Identity "InformationTechnology_50e33be9-426c-43e4-8dc4-4706544ab1a4" -PrimarySmtpAddress "InformationTechnology@localhost"

if you wish to remove the old alias or you can leave as it is.

Set-UnifiedGroup -Identity "Test o365Group" -EmailAddresses: @{Remove="InformationTech@careexchange.in"}

Enable or Disable Multi-factor Authentication in Office 365

There is a requirement on test environment tenant to disable multi factor completely

  • More Information required

https://portal.azure.com Login to Azure Portal

  • Properties
  • Manage Security Defaults
  • Choose No

Never do it in production environment unless there is certain need. Please note conditional policies makes this selection to no automatically as well.

Office 365 Mailbox not showing in Hybrid Exchange server

Newly created Mailbox not showing in Hybrid Exchange Server Control Panel.Not all administrators certainly know that they should not provision office 365 mailbox directly from the office 365 console. They should have used the Hybrid server to provision new cloud mailboxes.

User Created Directly on Active Directory and created a mailbox on Office 365 without using the hybrid server. Creating an issue on some mailboxes not visible in hybrid server

Below Commands will enable you to get the mailbox under Get-RemoteMailbox in Hybrid Exchange server.

Run on Azure AD Connect Server or Hybrid Exchange server with Active Directory Tools installed.

Please replace  domain / domain.com on 3 rd and 4th line with your appropriate domain names. You can get these info from a working mailbox.

$uid = read-host "Please enter username"
$mailnick = read-host "Please enter same username"
$tempmail = $uid+"@domain.mail.onmicrosoft.com"
$primarymail = $mailnick+"@domain.com"
Set-ADUser $uid -Clear homemdb, homemta, msExchHomeServerName, msExchPoliciesExcluded
Set-ADUser $uid -Add @{msExchRemoteRecipientType="4"}
Set-ADUser $uid -Add @{mailNickname="$mailnick"}
Set-ADUser $uid -Add @{msExchProvisioningFlags="0"}
 
Set-ADUser $uid -Add @{msExchModerationFlags="6"}
Set-ADUser $uid -Add @{msExchAddressBookFlags="1"}
Set-ADUser $uid -Replace @{targetaddress="$tempmail"}
Set-ADUser $uid -Replace @{msExchRecipientDisplayType="-2147483642"}
Set-ADUser $uid -Replace @{msExchRecipientTypeDetails="2147483648"}
Set-RemoteMailbox $uid -PrimarySMTPAddress $primarymail

This value you need to add from a working mailbox as the number differs with the exchange server version .
This one below is for exchange 2016 . Highly recommeneded to take it from a working mailbox.
If you skip this one it works but it will throw out a error later if you enable archive mailbox for the same user.

Set-ADUser $_.samaccountname -add @{msExchVersion="88218628259840"}

ArchiveGuid can’t be set on this object to enable archive mailbox


Bulk Script @azure365pro needs to be replaced in Line 6 and Line 7 Appropriately.

$upns = Import-csv m7.csv
foreach ($x in $upns)
{
$uid = $x.upn
$mailnick = $uid
$tempmail = $uid+"@azure365pro.mail.onmicrosoft.com"
$primarymail = $mailnick+"@localhost"
#Set-ADUser $uid -Clear homemdb,homemta,msExchHomeServerName,msExchPoliciesExcluded
#Set-ADUser $uid -Add @{msExchRemoteRecipientType="4"}
Set-ADUser $uid -Add @{mailNickname="$mailnick"}
Set-ADUser $uid -Add @{msExchProvisioningFlags="0"}
Set-ADUser $uid -Add @{msExchModerationFlags="6"}
Set-ADUser $uid -Add @{msExchAddressBookFlags="1"}
Set-ADUser $uid -Replace @{targetaddress="$tempmail"}
Set-ADUser $uid -Replace @{msExchRecipientDisplayType="-2147483642"}
Set-ADUser $uid -Replace @{msExchRecipientTypeDetails="2147483648"}
Set-RemoteMailbox $uid -PrimarySMTPAddress $primarymail
}

 

Copy and Paste Active Directory Attributes using PowerShell

Active Directory Powershell saves you hours of manual work where in this case i was asked to copy office name to ipphone attribute in bulkf for all users. it took only 5 mins for 3000 users. It all matters how well you use your powershell skills

Copying Office Name to IpPhone attribute in Bulk

$USERS = Get-ADUser -Filter {DisplayName -like "test1*"} -Properties physicalDeliveryOfficeName,Ipphone
foreach($user in $USERS)
{
$copy = $user.physicalDeliveryOfficeName
Set-ADUser $user -Replace @{ipPhone=$copy}
}

Clear the attributes using Powershell

Set-ADUser $_.samaccountname -Clear extensionAttribute10
× How can I help you?