Sunday, March 31, 2013

Using Recovery Storage Group in Exchange 2007

There are some major and significantly good changes in the Exchange 2007 RSG in comparison to the Exchange 2003 RSG and most of them are as a result of the powerful power shell capabilities.

In this article I will describe, step by step, how to configure RSG and how to restore an item or a mailbox from backup.

Requirements and naming conventions

For the purpose of this article, I've used the following objects:

* SQA-LCS2005 - Exchange 2007 standard edition.
* Administrator - Source & destination mailbox on SQA-LCS2005 to restore the selected items from the RSG.
* Backup software - Ntbackup (C:'Backup'ExchDB.bkf – is the backup device that I used).

The process is divided into 4 parts:

1. Having a backup of the DB, a backup that contains the items that were deleted.
2. Create the RSG in the Exchange server.
3. Restore the relevant items / mailbox – Using GUI.

Optional: Restore the relevant items / mailbox – Using MSH.

1. Dismount and remove the RSG.

Having a backup of the DB, a backup that contains the items that were deleted

Note that the backup process usually should run every day automatically; therefore you may skip this step.

Open the Ntbackup software, mark the DB you want to backup and verify that the backup completed successfully:

Create the RSG in the Exchange server

1. Open the EMC (Exchange Management Console), from the Toolbox node, click on the Database Recovery Management:

1. Type the name of your Exchange server and Domain Controller server name and then click Next at the bottom of the screen:

1. From the Tasks options, choose Manage Recovery Storage Group and then click on the Create a Recovery Storage Group:

1. Select the Storage Group that you want to restore from and click Next:

1. Choose the location of the original SG files (DB + Logs).

1. Finish the RSG creation.

1. Verify that the RSG was created using the Exchange Management Shell (MSH):

Restore the relevant items / mailbox – Using GUI

Note that the Administrator mailbox, before the emails deletion, looks as follows:

1. The first step in this section is restoring the DB from the backup.Open the backup software and choose the DB you want, and marked it to restore:

1. Mark the next parameters, as shown in the next screen:

1. Verify that the restore completed successfully.
2. After the restore completed successfully, click the Merge or copy mailbox contents from the Manage Recovery Storage Group:

1. In the mounted Database in the RSG that you restored, click Gather Merge information:

1. The next screen gives you the ability to restore the whole mailbox or all the items in the mailbox from the backup in a simple way by clicking the Perform pre-merge tasks:

1. If you want to filter the items that you want to restore, like items from a specific range of dates, restore the items with a specific subject from all mailboxes to a specific mailbox – you should select the Show advanced Options:

Note: In this example I have chosen to restore all the items with the word TEST (the search is not case sensitive) to the Test_Folder folder in the Administrator's mailbox.

Search by subject (TEST) and copy all the items that will be found to the Administrator's mailbox:

Search the TEST word in the next mailboxes:

1. The result of the process, is shown in the next screen:

Exchange 2003 Shutdown Script

http://www.amset.info/exchange/shutdown-script.asp

Shutdown Script for Exchange 2000/2003
Author: Simon Butler, Exchange MVP, MCSE

This is the Exchange 2003/2000 version of this article. For the Exchange 2007 version - go here.

If you are running Exchange on a domain controller, then you will find that it takes the machine a long time to shutdown. This is because the domain functionality stops quicker than Exchange, therefore Exchange is unable to write to the domain controller and has to be be "killed" by the operating system.

This continual "killing" of the Exchange services, instead of allowing them to shutdown gracefully is not good for the database and is one of the prime reasons for recommending that Exchange is not installed on a domain controller.

A better option is to stop the services before you begin to shutdown the server. This will also cause the server to shutdown more quickly because it isn't waiting for the services to timeout.

Even if you have a dedicated Exchange server, if you are using a UPS, then you may also want to shutdown the Exchange services before the UPS shuts down the OS. In many cases the domain controller may shut down before Exchange, which will cause delays as Exchange needs to communicate with the the domain controller during the shutdown process.

While you can stop the services yourself using the services administrative tool, instead use a batch script with a shortcut on the desktop. Below is a sample script. Simply copy and paste it in to a new notepad document and save it as "stop-exchange.cmd".

Note: These scripts use the Exchange 2003 service names, for other versions of Exchange, simply look in service manager for the full names of the service.

net stop "Microsoft Exchange Information Store" /y net stop "Microsoft Exchange System Attendant" /y net stop "Microsoft Exchange IMAP4" /y net stop "Microsoft Exchange Routing Engine" /y net stop "Microsoft Exchange POP3" /y net stop "Microsoft Exchange Management" /y

If you are using a third party plug-in, then you may find that there is a dependency on that plug-in which can cause the script to fail. The /y at the end of each command should deal with it, but if you find that the third party service doesn't stop in time, adjust the script to include a delay. (Sleep is part of the Windows Resource Kit tools, if you don't have it installed on the server)

For example, this is a script used with an old version of McAfee Group Shield

net stop "McAfee GroupShield Exchange" /y sleep 30 net stop "Microsoft Exchange Information Store" /y net stop "Microsoft Exchange System Attendant" /y net stop "Microsoft Exchange IMAP4" /y net stop "Microsoft Exchange Routing Engine" /y net stop "Microsoft Exchange POP3" /y net stop "Microsoft Exchange Management" /y

Finally, you might also want a script to start Exchange again. This can be useful if you apply an update which requires a restart of the Exchange services, but don't need to restart the server.

net start "Microsoft Exchange Information Store" net start "Microsoft Exchange System Attendant" net start "Microsoft Exchange MTA Stacks" net start "Microsoft Exchange IMAP4" net start "Microsoft Exchange Routing Engine" net start "Microsoft Exchange POP3" net start "Microsoft Exchange Management"

You will notice that there are different services listed in each script. That is because the scripts take advantage of dependencies, therefore allowing you to stop or start one service and due to the dependencies it stops or starts a number of other services automatically. The /y command will answer Yes to any questions about stopping dependant services at the same time.

Shutdown or restart the server afterward stopping Exchange

If you are using these scripts to shutdown Exchange before a server is shutdown (for example by a UPS) or rebooted, then you may want to fully automate the process by scripting the shutdown/restart as well. This can be easily achieved by adding an extra line to the end of the script:

Restart the server

shutdown /r /t 00

Shutdown the server

Wednesday, March 27, 2013

Delete Mail from Multiple Mailboxes (2k7\2k10)


Delete Mail from Multiple Mailboxes


IT Problem

I had this recently where an email had went around a school and was quite sensitive, I needed to find a way ofdeleting the email from every mailbox…and fast. Luckily this can be done in power shell So if you need todelete an email in powershell across the organization quickly follow the guide below.

Note the new section at the bottom of this article for deleting emails in exchange 2010 SP1

IT Solution

This can be done with power shell. See the command below.
NOTICE out of the box these commands are not enabled, you will need to see this article first if you have not already enabled them – Enable Export Mailbox Commands In Exchange 2010
Once the above is done you can now proceed
Get-Mailbox -Database mailboxdb | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent
Where  MailboxDB is your store and “Virus Message” is the content
You  will need to use an account that has the correct permissions to give the correct permissions to the user use this command
get-mailbox -Database "Mailbox Database"| add-mailboxpermission -user administrator -AccessRights FullAccess
That command will give the correct rights to the administrator account.



Delete Email From Exchange 2010 SP1

Microsoft changed a few commands for SP1  of exchange 2010.
In Exchange 2010 SP1, we use the  New-MailboxExportRequest and the New-MailboxImportRequest to exportimport emails. You also use this in conjunction with the  Search-Mailbox command and add the add parameter -DeleteContent.
For example,
Get-Mailbox -Server  "your server" | Search-Mailbox -SearchQuery 'Subject:"pictures of your mum"' -DeleteContent

Tuesday, March 26, 2013

Paging File Sizing in Exchange Server 2007



Refer this http://blogs.technet.com/mikelag/archive/2007/12/19/working-set-trimming.aspx
&&&&& the below:


Virtual memory is a mature, well-understood technology that was first developed in the early 1960s. It's a basic part of every computer science course on operating systems, and it's been a familiar part of Windows since Windows NT first shipped. The idea behind virtual memory systems is that applications (and the OS) can use disk space as a substitute for RAM. The virtual memory manager (VMM) swaps chunks, or pages, of memory in and out as applications request the contents of specific memory blocks. This procedure lets servers handle larger workloads without necessarily requiring a huge amount of physical RAM.
Of course, there's no such thing as a free lunch. If the amount of physical RAM in a computer is insufficient for its workload, the VMM must frequently swap pages to and from disk. As a result, performance can suffer because paging is a disk-bound operation.
Most administrators ignore the virtual memory subsystem in Windows, leaving it alone to do its job—an excellent idea, given that the VMM in Windows is largely self-tuning. It turns out, however, that in some cases you might need to adjust the size of the paging file, the disk-based store used to hold memory contents that are swapped out. Knowing when to adjust the paging file, and what size to use for it, will help you squeeze the best possible performance out of your Exchange servers.
You'll find the basic rule for paging file sizing for Exchange servers on Microsoft's"Exchange 2007 System Requirements" Web page. It's fairly simple: Set the paging file size to equal the amount of physical RAM in the server, plus 10MB. At first glance, this rule seems reasonable—until you consider that Exchange Server 2007, which requires a 64-bit Windows OS, can address large amounts of RAM by virtue of x64 Windows' support for much larger address spaces. Do you really need a 32GB paging file for a server with 32GB of physical RAM? After all, you might think that with so much RAM, the system will never need to page.
In a word, the answer is yes. Exchange 2007 dynamically adjusts the amount of RAM it uses for caching ESE database pages. This dynamic adjustment process was introduced in Exchange Server 5.5 and was known as Dynamic Buffer Allocation. Its implementation is nuanced, but it can be described simply: Exchange grabs as much RAM as it can, then gives back RAM when other applications require it.
One key measure that Exchange uses to decide when to reduce its cache size is the amount of paging going on. Say that you have a server with 16GB of RAM and a 1GB paging file. This configuration is way out of balance and will severely thrash the paging file—that is, generate a large volume of disk I/O by reading and writing pages from disk—when the system is under heavy load. Exchange detects the thrashing and backs off the amount of RAM it uses to cache ESE pages, which then increases the amount of disk I/O required for ESE access, a situation that further hurts server performance.
Paging isn't the only factor that affects how Exchange allocates RAM for its ESE cache, but it's the one that you have the most influence over. Microsoft recommends the nearly 1:1 paging file–to-RAM ratio to keep the amount of paging overhead low, which avoids misleading the Exchange cache allocation algorithm into taking too much or too little RAM. Why the recommendation to add 10MB beyond the server's physical RAM to the paging file? It turns out that Windows uses the paging file to cache some types of internal data (Microsoft hasn't said exactly what), and leaving that 10MB buffer lets Exchange and other memory-intensive applications use paging file space up to the amount of the physical RAM.



Wednesday, March 20, 2013

No roll back option for Exchange Service Packs


No, It's not possible to uninstall an Exchange Service Pack

What you should do is to patch your other servers.

Note:
  1. A CAS Server should always be the upgraded before HUB and MB
  2. SP2 hasn't been supported for over a year now.


There are schema changes for Exchange SP3, you also cannot roll it back, once you have installed it.

The Exchange Service Packs are complete installs and the only way to remove it would be to remove Exchange from the server completely.

Exchange 2k7 sp3 --> Allowing end-users to change their expired passwords using OWA (Outlook Web Access)


Password Change in OWA with Exchange 2007 SP3:

Now that we went through the process of installing Exchange Management Tools on Windows 7 and also on Windows Server 2008 R2, we can check one of the new features introduced in this new release which is the Exchange Server 2007 SP3 Password Reset Tool.
This tool is only for Exchange Server 2007 using IIS 7.x because SP3 creates a new module for that purpose on IIS 7 only. Bear in mind that this feature is only for the Client Access Server roles, if you have a NLB make sure to enable all of them with the steps that we will list in this article.
Before explaining the feature let's understand the context where this new feature can help the end-users. Basically when we create a new user or when a user password is reset and the option User must change password at next logon is selected (Figure 7), if the user tries to log on using OWA the user will receive the following error message:The user name or password that you entered is not valid. Try entering it again.
http://www.andersonpatricio.org/Tutoriais/Exchange2007/ap991_02.png
Figure 7
If you have ISA Server in order to publish your OWA you may not need to change anything since ISA has this feature built-in to fix the issue described previously. However, if you don’t have ISA, you have to publish Exchange Server using a different firewall make sure that the internal OWA is able to change expired passwords, then this new feature will help you.
Note:
If you are an ISA customer and want to validate if you are using a similar feature, this page can help you out. 
Okay, let’s go to the fun stuff. In order to enable OWA to change expired passwords, we can use the following steps:
  1. Logged on the Client Access Server
  2. Click on StartRun and type in regedit and click on OK
  3. Expand HKEY_LOCAL_Machine
  4. Expand System
  5. Expand CurrentControlSet
  6. Expand Services
  7. Click on MSExchange OWA
  8. Right-click on the right side, and click on New  and then DWORD (32 bit) value
  9. Let’s name the key as ChangeExpiredPasswordEnabled and its value will be 1, as shown in Figure 08
http://www.andersonpatricio.org/Tutoriais/Exchange2007/ap991_03.png
Figure 8
After changing the registry information we need to restart IIS, we can use IISReset /noforce and then we will be ready to start testing. The test is not a big deal, just create a new user and try to log on in OWA, the user will receive a new OWA form asking for the current password and the new password, as shown in figure 09.
http://www.andersonpatricio.org/Tutoriais/Exchange2007/ap991_04.png
Figure 9
After typing new passwords and hitting the Submit button, a new page will appear with the information that the password has been changed will be displayed. The user just needs to click OK (Figure 10) and then type in again the user name and the new password to access its OWA.
http://www.andersonpatricio.org/Tutoriais/Exchange2007/ap991_05.png
Figure 10
As you may have noticed, this article is showing some ways to automate the process. If you want to enable the feature described previously you can save the following lines in a file and save it as .ps1 and run it from a PowerShell session.
Write-Host "Adding ChangeExpiredPasswordEnable key in the registry..." 
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\MSExchange OWA" -Name "ChangeExpiredPasswordEnabled" -Value 1 -PropertyType "DWord" 
Write-Host "Restarting IIS using /noforce option.." 
IISReset /noforce
Note:You may have to use Set-ExecutionPolicy unrestricted in order to run the script.

Conclusion

In this article we validated the installation process of Exchange Server 2007 SP3 on top of the new Operating System supported by the product and also how to enable the Reset Password feature.

Monday, March 18, 2013

Purging any windows logs with Task Sheduler in Win 2003 & Win 2008

http://social.technet.microsoft.com/Forums/en-US/configmgrgeneral/thread/d989b249-0159-41fc-b78c-1f1d91ce8bb3/


The mistake I found in Tom Watson's script is the added backslash \ before the Cmd.exe string resulting in the following:
ERROR: Invalid syntax. '/C' option is not allowed more than '1' time(s).
Type "FORFILES /?" for usage.
The fix, at least in my case was to remove the backslash \ as shown below.
Windows 2003
at 12:00 /EVERY:Su Forfiles.exe -p C:\WINDOWS\system32\LogFiles\W3SVC1 -m *.log -d -30 -c "Cmd.exe /C del @path\"

Windows 2008
at 12:00 /EVERY:Su Forfiles.exe -p C:\inetpub\logs\LogFiles\W3SVC1 -m *.log -d -30 -c "Cmd.exe /C del @path\"