Exchange: Can’t Delete a Database

KB ID 0001414

Problem

Every iteration of Exchange comes up with some new system/hidden mailbox type that stops me deleting mailbox databases!

[box]

This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, public folder mailboxes or arbitration mailboxes, Audit mailboxes. To get a list of all mailboxes in this database, run the command Get-Mailbox -Database <Database ID>. To get a list of all mailbox plans in this database, run the command Get-MailboxPlan. To get a list of archive mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Archive. To get a list of all public folder mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -PublicFolder. To get a list of all arbitration mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -Arbitration. To get a list of all Audit mailboxes in this database, run the command Get-Mailbox -Database <Database ID> -AuditLog. To disable a non-arbitration mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID>. To disable an archive mailbox so you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -Archive. To disable a public folder mailbox so that you can delete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -PublicFolder. To disable a Audit mailbox so that you can delete the mailbox database, run the command Get-Mailbox -AuditLog | Disable-Mailbox. Arbitration mailboxes should be moved to another server; to do this, run the command New-MoveRequest <parameters>. If this is the last server in the organization, 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 <MailboxPlan ID> -Database <Database ID>.

[/box]

 

Solution

OK, I’m assuming you don’t actually have any mailboxes in the database? The following will tell you;

[box]Get-Mailbox -Database “Database-Name“[/box]

If you are running Exchange 2016 you might have an AudiLog account;

[box]Get-Mailbox -Auditlog -Database “Database-Name“[/box]

Or a Monitoring Mailbox

[box]Get-Mailbox -Monitoring -Server “Server-Name“[/box]

For 2013 (and older) the likely culprits are Arbitration, Archive, or Discovery Search mailboxes, (the latter you need an extra command to see).

[box]Get-Mailbox -Auditlog -Database “Database-Name” -Arbitration

Get-Mailbox -Auditlog -Database “Database-Name” -Archive

Set-AdServerSettings -ViewEntireForest $true

Get-Mailbox -Database “Database-Name“[/box]

To move a Discovery Search Malbox

[box]Get-Mailbox DiscoverySearchMailbox* | New-MoveRequest -TargetDatabase “Target-Database“[/box]

Also Exchange 2013 or Newer may have one or more Public folder mailboxes;

[box]Get-Mailbox -PublicFolder | New-MoveRequest -TargetDatabase “Target-Database“[/box]

I Can’t Find Anything and it still Wont Let Me Delete the Datastore?

Well, there’s two things you can do;

1. On a Domain Controller, 0pen ADSIEdit.msc and Connect to ‘Configuration’. Navigate to Configuration > Services > Microsoft Exchange > {Organisation name} > Administrative Groups > {Administrative-Group-Name} > Databases  >Delete the database from here (BE CAREFUL CHECK TWICE, DELETE ONCE!). Then have a coffee refresh you datastore view and the offender will disappear.

2. With the database dismounted, move its .edb file to another folder, then mount the store, it will complain and ask if you want to mount and empty store > select ‘yes’ > You can then delete it.

 

Related Articles, References, Credits, or External Links

NA

Deleting Folders With ‘Long Filenames’ (Source Path Too Long)

KB ID 0001396

Problem

Source Path Too Long
The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) before attempting this operation.

“Have you come across a problem deleting folders with long filenames?” I got asked this question twice in the first week at a new job. In a former role my colleague did a lot of work in schools and was forever coming across this problem when doing file migrations.

As it transpired this was a problem at, yes you’ve guessed it a school that was a client. The little darlings had got hold of a script that recursively created nested folders, and as obviously this is hilarious it had happened multiple times.

I didn’t have a solution of the top of my head, but I thought I’d try and recreate the problem, and see if there was a simple solution.

Solution

The most difficult part was replicating the script. Windows is pretty good at protecting itself. But thanks to the good folk at Experts-Exchange’s assistance, I was good to go, attempting to move or delete the file generated the error you see above.

Method One: Use Robocopy

Robocopy has been built into windows for a while, you can use it with the /MIR flag to remove all your subfolders.

[box]

MD C:\DELETE-ME
robocopy C:\DELETE-ME C:\{path}\{The Top Level Folder To Delete} /s /mir

[/box]

Then you can simply delete the two remaining empty folders

[box]

rd C:\DELETE-ME
rd C:\{path}\{The Top Level Folder To Delete}

[/box]

Method Two: Use a GUI Tool

I’m always suspicious of third party tools, and if you Google this problem two pieces of software will jump out, one’s brilliant does not have any spamware or malware in it, the other one’s, well not free and annoying.

The Good

DeleteLongPath by BackupChain simple and does exactly what you expect. Take some time to look a their backup software as well!

The Bad

Message boards are spammed with people saying how great this piece of software is, probably by the clowns who make it! Long Path Tool, they just want your money don’t bother. 

Update: I’ve had about 15 to 20 chancers trying to post favourable comments for this piece of junk, don’t bother i wont approve them!

 

Related Articles, References, Credits, or External Links

NA

Windows – Cannot Delete Thumbs.db

KB ID 0000683

Problem

Thumbs.db is a small hidden system file that gets generated when you view media in a folder, you know when you look at all your MP3 songs and you can see the album cover as a thumbnail? Or you can see what all your photos are as a tiny thumbnail before you open them, well thats what the thumbs.db file is doing. It’s a tiny cache of all that information so next time someone visits this folder it displays those pictures quicker. Well that’s great! But when you try and delete a folder with one in (particularly a folder on another machine) you can see the error below.

The file Thumbs.db is a system file if you remove it, Windows or another program may no longer work correctly.

Then it won’t let you delete it, and if you persist, you end up with a folder with just this file in it, that you cant delete.

Solution

First Step – Delete the Thumbs.db file

OK, lets solve the initial problem first and get rid of the one thats annoying us at the moment.

1. In Windows 8/2012 whilst in the folder > File > Open command prompt as administrator. (With older versions of windows hold down SHIFT and right click).

2. Issue the following commands;

[box] attrib -s -h thumbs.db del thumbs.db [/box]

Stop your PC Generating Thumbs.db Files

Option 1

Open Windows Explorer > View Options > Change folder and Search Options > View > Enable ‘always show icons, never thumbnails’ > Apply > OK.

Option 2 (Use the Local Policy of the Machine)

1. Press Windows Key+R to launch the run menu > gpedit.msc > OK.

2. Navigate to;

[box] User Configuration > Administrative Templates > Windows Components > File Explorer {or Windows Explorer} [/box]

Locate the ‘Turn off caching of thumbnail pictures’ policy.

3. Enable > Apply > OK.

Option 3 (Use the Registry)

You can simply run the following command;

[box] REG ADD “HKCUSoftwarePoliciesMicrosoftWindowsExplorer” /v “DisableThumbsDBOnNetworkFolders” /t REG_DWORD /d 1 /f [/box]

Or to do it manually,

1. Press Windows Key+R to launch the run menu > gpedit.msc > OK.

2. Navigate to;

[box] HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Explore > Advanced [/box]

Create a New DWORD Value.

3. Call it DeleteThumbnailCache and set its value to 1.

Remove all Thumbs.db Files

Finally lets tidy up any remaining thumbs.db files.

Option 1

1. Open Windows Explorer (Windows Key+E) > Right click the drive > Properties > Disk Cleanup.

2. Select Thumbnails > OK.

Option 2

1. From command line, issue the following commands;

[box] cd del thumbs.db /s /q [/box]

 

Related Articles, References, Credits, or External Links

NA