Exchange: Mailbox Folder Size Report


As an Exchange Administrator, you can generate a mailbox folder size report for any user. It is extremely helpful if the USER doesn’t know how his/her mailbox is reaching size limit & which FOLDER has most emails.

Well here is the one-liner PowerShell script (Note: Replace username@company.com with user’s email address):

Get-MailboxFolderStatistics username@company.com | Select-Object FolderPath,@{Name="SubFoldersize";Expression={$r=$_.FolderAndSubfolderSize; [int] $a = ($r.Substring($r.IndexOf("(")+1,($r.Length - 2 - $r.IndexOf("("))) -replace " bytes","" -replace ",","") ; $a } } | Sort-Object SubFolderSize -Descending | Select-Object FolderPath,@{Name="Folder-and-Subfolder-Size";Expression={[String] $_.SubFolderSize + " MB"}}

The sample output shows this:

FolderPath                                       Folder-and-Subfolder-Size
 ----------                                       -------------------------
 /Scheduled Reports                               1625 MB
 /incoming Unapproved emails                      1165 MB
 /Audits                                          907 MB
 /Compliants                                      562 MB
 /Policy Violation Compliants                     551 MB
 /Deleted Items                                   482 MB
 /Server Activity Summary                         449 MB
 /VM Approval Requests                            236 MB
 /Approved Requests                               71 MB
 /New Accounts                                    61 MB
 /Profile Review                                  57 MB
 /Authorizations                                  35 MB
 /Rejected Content                                11 MB
 /Sent Items                                      8 MB
 /PersonMetadata                                  6 MB
 /Contacts                                        3 MB
 /Contacts/Recipient Cache                        3 MB
 /Calendar                                        0 MB
 /Drafts                                          0 MB
 /Quick Step Settings                             0 MB

You can export this to CSV file by adding “| Export-CSV -Path .\MBFolderSizeReport.csv -NoTypeInformation”. If it helped you, leave me a “Thanks” in the comments.

Windows Server 2016/2019: Where the hell the time zone settings?


If you are trying right-clicking on Date/Time on task bar, choosing Adjust date/time:

Configure Date, Time and Time Zone settings in Windows Server 2016

And you are stuck at Windows new settings page, where changing the time zone doesn’t take effect. Here you say: “What the HELL?”

So, I say go for old Time settings from control panel to change the time zone. Here is how you can do it:

  • Press Windows Key + R to open the Run dialog.
  • Type “control timedate.cpl

You have been served with the old setting dialog, change the time zone here by clicking on “Change Time Zone” button

Or you can also get here from the Server Manager >> Local Server >> Click on the Timezone..

Hope this blog is useful for you.

Promoting a DC: Error determining whether the target environment require adprep


When you are promoting a new Domain Controller in to an existing Active Directory Forest/Domain, you let the default setting of “Any domain controller” to sync from and you are stuck at promotion process with this error message:

Error determining whether the target environment require adprep:  
Validation error Validation error: Unable to make an LDAP connection to server RandomDC01.company.com 
Exception: The specified server cannot perform the requested operation  Details: Test.VerifyForestUpgradeStatus.ADPrep.Win32Exception.-2147467259

If I choose a closest domain controller manually, you still the ‘freaking’ error message:

Error determining whether the target environment require adprep:
Validation error Validation error: Unable to check forest upgrade status for server ClosestDC1.company.com
Exception: The specified server cannot perform the requested operation
Details: Test.VerifyForestUpgradeStatus.ADPrep.Win32Exception.-2147467259

OK, now. What seems to be the ‘problem’? I believe the new server being promoted to a DC is NOT seeing the network or any domain controllers correctly. Check these few possible issues/solutions:

  1. Is the new server pings any other domain controllers? Can you Telnet port 389? Fix the Network card (IP, subnet or bad driver)
  2. Is any Firewall between the new server to existing domain controllers? Check here what firewall ports needs to open – https://support.microsoft.com/en-us/help/179442/how-to-configure-a-firewall-for-domains-and-trusts
  3. Is this new server a VM? check it is connected to correct (software) swtich/VLAN.

When you demoting a domain controller, you receive the “Failed to modify the necessary properties for the machine account. Access is denied” error message


Are you getting this error message when demoting a domain controller?

“The operation failed because: The Active Directory Domain Services Installation Wizard (DCpromo.exe) would not configure the computer account <2012 DC> on the remote Active Directory Domain Controller <2019 DC>. Verify that the user running dcpromo.exe is granted the “Enable computer and user accounts to be trusted for delegation” user right in the Default Domain Controllers Policy. The error was: Access is denied”

If you didn’t enable the GPO setting for “Enable computer and user accounts to be trusted for delegation”, by all means enable it and then run GPUpdate /force command on the domain controller before demoting the DC.

If the GPO setting is already enabled, AD replication is done, GPUpdate.exe updated the setting on the domain controllers and you see the setting enabled in RSOP.exe results. BUT you still getting the same freaking error again. What do you do now?

In my case, computer account for Domain Controller is enabled with the setting “Protect object from accidental deletion“. I disabled this check box, then demotion went without errors.

See the source image

Active Directory: Self-Signed certificate for LDAPs


While testing Active Directory on a closed private network, I needed LDAPs connections to the domain controllers. But I didn’t have any PKI/Certificate servers on the network and I didn’t want to build one.

So I decided to use a self-signed SSL certificate for LDAPs connections. If you reading this, you need one too. Here is how I did it.

  • Logon to the Domain Controller
  • Open PowerShell in elevated mode (Right-click on PowerShell, choose Run as Administrator)
  • Next Run the New-SelfSignedCetificate cmdlet. NOTE: Replace the DnsName to your server’s FQDN name and NetBIOS name.
New-SelfSignedCertificate -DnsName SanFran-DC01.company.com, sanfran-dc01 -CertStoreLocation cert:\LocalMachine\My 
  • This cmdlet will create a self-signed cert with given DNSName and place it at Local Computer certificate store.
  • Last step: Open Certificate console by click Start button & type Manage Computer Certificates and open it from the search results.
  • Expand Personal >> Certificates and also expand Trusted Root Certificates >> Certificates
  • Find the newly generated Self-Signed SSL Certificate in Personal >> Certificates.
  • Select the Self-Signed Certificate and drag & drop to Trusted Room Certificates >> Certificates to trust the certificate on the domain controller.
  • Close the Certificate console

Now you are ready to do LDAPs to this domain controller. If you want to validate it works, you can use LDP.exe tool.

  • Open LDP.exe on the domain controller (or any other computer on the network)
  • Click Connection menu and choose Connect…
  • Type the domain controller FDQN and Port number as 636 and click OK. You should see “Established connection to <domain controller>” and the Base DN details.

Did this blog help you? Leave me a reply!

PowerShell: Find if a computer is waiting for Reboot (pending reboot)


To find a computer is waiting for reboot to complete the Microsoft Update installation, I have found this information in Windows Update WMI object. This displays True (if Pending Reboot),or False (Not waiting for reboot).

(New-Object
-ComObject Microsoft.Update.SystemInfo).RebootRequired

But this only runs on the local computer. I needed to collect Pending Reboot state of all of our servers. That’s when I found this Gem – PowerShell Module – written by Brian Wilhite at Here.

It’s perfect. First you need to install this module on your local computer. Run this command on a elevated PowerShell (Run-As Administrator).

Install-Module -Name PendingReboot

You can close the elevated PowerShell. Use this module on your script to find Pending Reboot state and why it needs reboot.

Here is the example how it works:

PS E:\> Import-Module PendingReboot
PS E:> Test-PendingReboot -ComputerName SFOExch01 -Detailed -SkipConfigurationManagerClientCheck
ComputerName : SFOExch01
ComponentBasedServicing : False
PendingComputerRenameDomainJoin : False
PendingFileRenameOperations : True
PendingFileRenameOperationsValue : {\??\C:\Program Files\Common Files\Microsoft Shared\ClickToRun\ApiClient.dll.bak, , \??\C:\Program Files\Common Files\Microsoft
Shared\ClickToRun\C2RINTL.en-us.dll.bak, …}
SystemCenterConfigManager :
WindowsUpdateAutoUpdate : False
IsRebootPending : True