Tagged: System Admin

3 Exchange Script that can save your time

Get Total Mailbox in each Mailbox Database

$Count = @{}
$Total = 0
Get-MailboxDatabase -Identity *<DB Prefix/Suffix>* |sort Name |ForEach-Object{
$MBs = Get-Mailbox -Database $_.Name
$Total = $Total + $MBs.count
$Count.Add($_,$MBs.count)
}

$Count | sort Name | Format-Table Name, Value
Write-Host "Total = " $Total

MailboxCount

Create an Exchange mailbox database + set all the standard settings + add copy of the DB to a DAG server

$DBName = "MYDB1"
$OriCopy = "ExchangeServer1"
$DAGcopy = "ExchangeServer2"

New-MailboxDatabase -Name $DBName -Server $OriCopy -Confirm -EdbFilePath "E:\Exchange_DB\$DBName\$DBName.edb" -LogFolderPath "E:\Exchange_DB\$DBName\TL" -OfflineAddressBook "\My-OAB" -PublicFolderDatabase "My Public Folder" -Verbose
Start-Sleep -Seconds 300
Set-MailboxDatabase -Identity $DBName -RecoverableItemsQuota 512MB -RecoverableItemsWarningQuota 400MB -IssueWarningQuota 230MB -ProhibitSendQuota 245MB -ProhibitSendReceiveQuota 256MB
Start-Sleep -Seconds 10
Mount-Database -Identity $DBName
Start-Sleep -Seconds 15
Add-MailboxDatabaseCopy -Identity $DBName -MailboxServer $DAGcopy
Start-Sleep -Seconds 10
Set-MailboxDatabase $DBName -CircularLoggingEnabled $true
Dismount-Database -Identity $DBName
Start-Sleep 20
Mount-Database -Identity $DBName

Move mailbox from a DB to another if Mailbox size and Mailbox Dumpster size is match the criteria

$SourceDB = "EDB01"
$TargetDB = "EDBT01"

$mbxs = Get-Mailbox -Database $SourceDB| Get-MailboxStatistics | where {($_.TotalItemSize -lt 256MB) -and ($_.TotalDeletedItemSize -lt 512MB)}


$mbxs | ForEach-Object{

	Get-Mailbox $_.DisplayName | New-MoveRequest -TargetDatabase $TargetDB

}


Change Scope in Exchange Management Shell (EMS)

If you are an Exchange admin in a large organization where you have multiple domain in a forest and you just want to see all the Exchange object in the forest, you can use the following cmdlet

Capture

Set-AdServerSettings -ViewEntireForest $True

to change back, just change from $true to $false
Set-AdServerSettings -ViewEntireForest $false

Note:

In this mode, be careful when you ran any cmdlet as it will display all the related object in the environment if you are not careful with it. Eg. Get-Mailbox will list out all the mailbox in the forest. Imaging 20,000 mailboxes.
And to top it, Get-Mailbox -Database DBNAME | New-MoveRequest -TargetDatabase TARGETDBNAME. If you are not careful, you might move some other domain mailbox to yours. ahaha!

Windows: Access denied when trying to access admin tools (.msc)

As a good system admin, I start my day by doing all the routine checks on all of my server and being a system admin in a Windows/Microsoft environment, it is natural to use the admin tools that were available out of the box.

As usual, I’ll open all the admin tools to start my daily checkups and to my surprise, I was prompted “Access is denied for dsa.msc”. I tried to open other admins tools and as expected, I get the same message. I’ve checked my system drive permission and my access level and it seems ok for me. So back to basic, I googled and found a solution to the problem from some forum (sorry can’t remember it but I’ll post the link once I found it).

So here are the steps to gain back the access to your admin tools

1 – go to Start > Run and type in “RegSvr32 MSXML.DLL” and press ok. Repeat the step but replace with “RegSvr32 MSXML2.DLL” and “RegSvr32 MSXML3.DLL

*Note: Should you get any error during this step, try install Microsoft Core XML Services (MSXML)

2 – Navigate to %SystemRoot%\System32 and look for the files with the .msc extension.

3 – Right click on any of the files and select Properties

4 – Change the open with by clicking on the Change button and browse to %SystermRoot%\system32\mmc.exe and click OK.

5 – Open any of the admin tools to make sure its working

I’m still investigating this issue. It might be a virus but that just my assumption. Will post later if I found something.

-Lokman-