Set IP address on DAG for exchange 2010/2013

Find the current IP address configuration of the DAG, run the command (DAG01 is my name of DAG)

Get-DatabaseAvailabilityGroup -identity "DAG01" | fl *ip*


Configure a IP address (say for the DAG, run

Set-DatabaseAvailabilityGroup -identity "DAG01" -DatabaseAvailabilityGroupIpAddress

You can configure multiple IP addresses for the DAG. To configure multiple ip addresses, run

Set-DatabaseAvailabilityGroup -identity "DAG01" -DatabaseAvailabilityGroupIpAddress,

Active Directory Authoritative and Non-Authoritative Restore Server 2008

Take systemstate backup.

After installation of Role Windows Backup/Restore with Command line option selected, Run wbadmin from an elevated command prompt. (To open an elevated command prompt, click Start, right-click Command Prompt, and then click Run as administrator

Syntax: Wbadmin start systemstatebackup –backupTarget: <VolumeName>[-quiet]
Example: Wbadmin start systemstatebackup –backupTarget:D:

Restore Server 2008 Active Directory (non-authoritative)

1. On Server 2008 DC, open the command prompt on the server.

2. Run below commands to enter Directory Services Restore Mode (DSRM).

Bcedit / set safeboot dsrepair
Shutdown –t 0 -r

Note: To manually boot in Directory Services Restore Mode, press the F8 key repeatedly. Use the up/down arrow keys to select Directory Services Restore Mode or DS Restore Mode. Then press the Enter key.

3. Login using administrator and DSRM password.

4. Run below command (note that e: is the drive letter of your backup), this will show you the version identifier of the backup.

Wbadmin get versions –backuptarget:D:

5. Run below command to start the restore.

Wbadmin start systemstaterecovery -version:18/09/2013-16:57–backuptarget:d:

6. After the restore process is completed, run following commands to reboot.

Bcedit /deletevalue safeboot
Shutdown –t 0 -r

Restore Server 2008 Active Directory if Someone Accidentally Deletes an Object. (Authoritative restore)

1.Restore Server 2008 Active Directory (non-authoritative), do not reboot the server

2. Open command prompt, run following commands, where CN=Sumit,OU=IT,DC=SYSGHOST,DC=LOCAL is the object you wish to restore.

ntdsutil: activate instance ntds

Active instance set to “ntds”.

ntdsutil: authoritative restore

authoritative restore: restore object CN=Sumit,OU=IT,DC=SYSGHOST,DC=LOCAL

3. Once it’s completed. Type quit

4. After the restore process is completed, run following commands to reboot.

     Bcedit /deletevalue safeboot
Shutdown –t 0 -r

Set User Principal Name (UPN) via Powershell

In case you need to change the UPN in Active Directory for all the users in particular OU you can use the powershell command

For example, I want to change all user’s to i will use the following command:

Get-ADUser -Filter * -SearchBase 'OU=XYZ,OU=USERS,DC=xyz,DC=com' -Properties userPrincipalName | foreach {Set-ADUser $_ -UserPrincipalName ("{0}@{1}" -f $,"")}

To confirm if there are any users with UPN i will use the following command in powershell:

Get-ADUser -Filter {UserPrincipalName -like "*"} | Select UserPrincipalName

Common Exchange Server Powershell commands

To see each database size:

Get-MailboxDatabase -Status | select ServerName, Name, DatabaseSize

Exchange 2010 mailbox size list in particular database:

Get-MailboxDatabase “<insert database name>” | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount

White Space (AvailableNewMailboxSpace) check with PowerShell:

Get-MailboxDatabase -Status | select Name, DatabaseSize, AvailableNewMailboxSpace

This example permanently deletes the soft-deleted mailbox for Ayla from mailbox database MBD01.

Remove-StoreMailbox -Database MBD01 -Identity Ayla -MailboxState SoftDeleted

This example permanently deletes all soft-deleted mailboxes from mailbox database MBD01.

Get-MailboxStatistics -Database MBD01 | where {$_.DisconnectReason -eq “SoftDeleted”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}

This example permanently deletes the disabled mailbox with the GUID 2ab32ce3-fae1-4402-9489-c67e3ae173d3 from mailbox database MBD01.

Remove-StoreMailbox -Database MBD01 -Identity “2ab32ce3-fae1-4402-9489-c67e3ae173d3″ -MailboxState Disabled

Managing calendar permissions in Exchange Server 2010/2013

we got 4 -MailboxFolderPermission cmdlets in Exchange Server 2010:

The following command will give everybody read rights to the calender in the “MeetingRoom” calendar.

Add-MailboxFolderPermission MeetingRoom@domain.local:calendar -User Default -AccessRights reviewer

The following command will give the users that are members of the AD group Res-CalendarAdmins read and write access to the calendar. (The AD group must be mail enabled and cannot be hidden from the address book when executing the command).

Add-MailboxFolderPermission MeetingRoom@domain.local:calendar -User Res-CalendarAdmins -AccessRights editor

The following command will remove access rights for the default user on mailbox

Remove-MailboxFolderPermission MeetingRoom@domain.local:calendar -User Default -AccessRights editor

The following command will show the actual rights to the calendar for the MeetingRoom.

Get-MailboxFolderPermission MeetingRoom@domain.local:calendar



ADD / Remove ProxyAddresses from Active directory Attributes

After Migration or Removing some domain from organisation, you might also need to remove SMTP address lists from Adctive directory.

For example: I have removed a domain from my active directory and now i want to remove all the from “ProxyAddresses” in active directory.

To do this, open notepad and write this code given below and then save it as scriptname.ps1

Import-Module Activedirectory

GC C:input.txt | % {

Set-ADUser $_ -Add @{ProxyAddresses="SMTP:$"}




If you want to remove Proxy Addresses then replace -Add with -Remove

and the input.txt file be containing all the usernames like:


place the input file in c:input.txt and run the script.


Configure Deduplication in Windows Server 2012

Windows 2012 deduplication segments files into small chunks and stores any duplicate chunks as a single chunk to save on space. The chunks are between 32 and 128 KB in size. Data deduplication can only be enabled on NTFS. Also, deduped drives cannot be system or boot volumes.

First is installation of  deduplication feature on server by following powershell command:

Install-WindowsFeature FS-Data-Deduplication


To enable Deduplication type the following command:

Enable-DedupVolume D:


To get a list of volumes that have deduplication enabled:



To check the settings configured for deduplication on volumes use the command:

Get-DedupVolume | fl


If you set MinimumFileAgeDays to 0 days, it will process all files no matter their age.

To change the “MinimumFileAge” for instance:

Set-Dedupvolume E: -MinimumFileAgeDays 0


To see the schedule for deduplication:


To see detailed of schedule:

Get-Dedupschedule | fl


As you can see from the illustration below there are 3 job types.

1. Optimization- Runs once an hour. This job deduplicates and compresses file chunks on the volume.

2. Garbage Collection- Runs once a week. Removes any chunk files that are no longer referenced to reclaim space.

3. Scrubbing- Runs once a week. Verifies data integrity and attempts to fix any corruption it finds.

To setup deduplication manually you can also create a manual deduplication job as following:

New-dedupschedule -Name “Deduplication Manual” -Type Optimization -Days Sat -Start 16:00 -DurationHours 12


After all this Deduplication will be configured and you can also check this in Tash Scheduler in Administrative tools:



you can also use Deduplication Evaluation Tool (ddpeval.exe) to calculate space on windows before installation of feature.