Monthly Archives: June 2018

Problems deleting a old mailbox database

I have a customer, where we have taken over the support from an old supplier, so we don’t know much about their background.

The first thing we do, was to update the Exchange Server.
But after have move all mailboxes, public folders, system mailbox.

I still got this error:

This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, or arbitration mailboxes. To ge
t a list of all mailboxes in this database, run the command Get-Mailbox -Database <Database ID>. To get a list of all m
ailbox plans in this database, run the command Get-MailboxPlan. To get a list of archive mailboxes in this database, ru
n the command Get-Mailbox -Database <Database ID> -Archive. To get a list of all arbitration mailboxes in this database
, run the command Get-Mailbox -Database <Database ID> -Arbitration. To disable a non-arbitration mailbox so that you ca
n delete the mailbox database, run the command Disable-Mailbox <Mailbox ID>. To disable an archive mailbox so you can d
elete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -Archive. Arbitration mailboxes should be move
d to another server; to do this, run the command New-MoveRequest <parameters>. If this is the last server in the organi
zation, run the command Disable-Mailbox <Mailbox ID> -Arbitration -DisableLastArbitrationMailboxAllowed to disable the
arbitration mailbox. Mailbox plans should be moved to another server; to do this, run the command Set-MailboxPlan <Mail
boxPlan ID> -Database <Database ID>.

Mailbox Plan is only used on the cloud.

I have look every places, unto i run this command:

dsquery * domainroot -attr * -limit 0 > result.txt

i then open the result.txt in notepad, and found some reference to the old database

msExchDisabledArchiveDatabaseLink: CN=Exch2013MB_Archive,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=Fibia,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=XXXX,DC=local

After delete this reference, i could delete the database.

 

 

 

MSSQL Free Space in Databases files

To get a list of the databases files, and the current disk size in MB, and the Free Space in MB in each fil, you can use this commands

USE [DATABASE_NAME]

SELECT DB_NAME() AS DbName, 
name AS FileName, 
size/128.0 AS CurrentSizeMB, 
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB 
FROM sys.database_files;

If you need a overview of all yours database this TSQL can be used

CREATE TABLE #FileSize
(dbName NVARCHAR(128), 
    FileName NVARCHAR(128), 
    type_desc NVARCHAR(128),
    CurrentSizeMB DECIMAL(10,2), 
    FreeSpaceMB DECIMAL(10,2)
);
    
INSERT INTO #FileSize(dbName, FileName, type_desc, CurrentSizeMB, FreeSpaceMB)
exec sp_msforeachdb 
'USE [?]; 
 SELECT DB_NAME() AS DbName, 
        name AS FileName, 
        type_desc,
        size/128.0 AS CurrentSizeMB,  
        size/128.0 - CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files
WHERE type IN (0,1);';
    
SELECT * 
FROM #FileSize
WHERE dbName NOT IN ('distribution', 'master', 'model', 'msdb');
    
DROP TABLE #FileSize;