Thursday, April 07, 2005

Blat

Blat is a command line email tool (sending mail via smtp), written for Windows. Blat is ideally suited for inclusion in scripts or automated runs to add email capability to your processes. Blat can be found at http://www.blat.net

Uptime Server Script

The following script was originally developed by Rick Campbell in 2003 and queries AD for all servers within a domain. It takes the results of the query and saves them to a file. Once this file is created, it then uses the file to pass server names to the UPLOAD.EXE application using a -S parameter to display detailed up time information for the servers. Each result is stored in a separate file labeled the same as the server name. The script then queries each of these files for the number of days the server has been online and adds them to an HTML file.

I modified this script to remove the AD query portion so I could manually control the servers included in the report.

@Echo OFF
@If not "%OS%"=="Windows_NT" Goto DOSEXIT
Title Uptimes

::
:: UPTIMES_HTML.BAT
:: Written 04/25/03 by Rick Campbell
:: Modified my Michael Henderson 04/03/2005
::
:: This script generates an HTML file that has the uptimes For all the member
:: servers and domain controllers in the domain. It also creates history files
:: of each server that can be clicked on from the HTML file.
::
:: This script uses the UPTIME.EXE program from the Win2k Resource kit and a
:: third party tool called NETVIEW.EXE from http://www.optimumx.com/download
:: as well as 1 small jpg file for the icon used in the html output.
::

Setlocal
Set SCRIPTNAME=%~n0
Set SCRIPTPATH=%~f0

Set ServersFile=servers.txt
Set ServersTemp=svrs.txt
Set HTMLfile=\\gnsmsgmon\reporting$\uptime.html
Set OldHTMLfile=\\gnsmsgmon\reporting$\uptime_old.html

Set /a ServerCount=0

Echo Getting Uptimes For all domain servers. Please wait...

:: Dump all the NT/2K servers/controllers to text file.
:: netview /nts /pdc /bdc /b /domain:corpmsg > %ServersTemp%

:: Now sort the file in aphabetic order based on computer name
:: sort %ServersTemp% /+3 /output %ServersFile%

:: Backup yesterday''s file
:: Del %OldHTMLfile% > nul
:: Ren %HTMLfile% %OldHTMLfile% > nul

:: Create the HTML file header
Echo ^^^ > %HTMLfile%
Echo BODY { >> %HTMLfile%
Echo font-size:10 pt; >> %HTMLfile%
Echo font-family: Verdana; >> %HTMLfile%
Echo } >> %HTMLfile%
Echo H3 { >> %HTMLfile%
Echo font-size:12 pt; >> %HTMLfile%
Echo font-family: Verdana; >> %HTMLfile%
Echo } >> %HTMLfile%
Echo TH { >> %HTMLfile%
Echo font-family : Verdana; >> %HTMLfile%
Echo font-size : 12; >> %HTMLfile%
Echo } >> %HTMLfile%
Echo TD { >> %HTMLfile%
Echo font-family : Verdana; >> %HTMLfile%
Echo font-size : 12; >> %HTMLfile%
Echo } >> %HTMLfile%
Echo ^^ >> %HTMLfile%
Echo ^^ >> %HTMLfile%

Echo ^Server Uptimes/Info For Domain: CORPMSG ^ >> %HTMLfile%

Echo Legend: ^ >> %HTMLfile%
Echo ^ ^ >> %HTMLfile%
Echo ^ Up For 0 - 5 days ^ >> %HTMLfile%
Echo ^ Up For 5 - 10 days ^ >> %HTMLfile%
Echo ^ Up For 10 - 50 days ^ >> %HTMLfile%
Echo ^ Up For 50 - 100 days ^ >> %HTMLfile%
Echo ^ Up More than 100 days^ >> %HTMLfile%
Echo ^^^ >> %HTMLfile%

Echo ^ >> %HTMLfile%
Echo ^ Server^ >> %HTMLfile%
Echo ^ Uptime^ >> %HTMLfile%

:: Now get the uptime For each server and write to HTML file.
For /f %%i in (%ServersFile%) do (Call :write_uptime %%i)

Echo ^Total number of systems: ^%ServerCount%^^ >> %HTMLfile%
::Echo ^Yesterday''s ^Uptimes^^ >> %HTMLfile%
Echo ^^Scan Date %Date% - At %Time% >> %HTMLfile%
Echo ^^ >> %HTMLfile%

:: Delete the temporary and log files.
:: Del svrs.txt > nul
:: Del servers.txt > nul
Endlocal & Goto :EOF

:WRITE_UPTIME
Setlocal
Set server=%1
Set daysup=-1

uptime %server% > nul

If %errorlevel%==0 (
:: Determine and write the number of days system has been up
For /f "tokens=6 delims= " %%i in ('uptime.exe %server% ^ Find "up for:"') do (
Set daysup=%%i
Echo %server% has been up For %%i days
)
)

:: Write system name as a link pointing to the uptime history file
Echo ^ ^^ >> %HTMLfile%
Echo ^^%server:~2%^ >> %HTMLfile%

Call :day_color %daysup%

Echo ^^ >> %HTMLfile%

:: Generate uptime history file and diagnostics report.
uptime.exe %server% /s > file:////servername/sharename$/files/%server:~2%.txt

Endlocal & Set /a ServerCount+=1 & Goto :EOF

:DAY_COLOR
:: Write the number of days the system has been up and determine the
:: Color to use For the amount of uptime, then write this to the file.
Setlocal
Set days=%1
Set daycolor=green
Set width=%days%

If %days% GTR 5 Set daycolor=blue
If %days% GTR 10 Set daycolor=orange
If %days% GTR 50 Set daycolor=yellow
If %days% GTR 100 Set daycolor=red

If %days%==-1 (
Set days=0
Set width=0
Set daycolor=Black
)

Echo ^ %days% day(s)^ >> %HTMLfile%
Echo ^ ^ >> %HTMLfile%
Endlocal & Goto :EOF

:DOSEXIT
Echo This script requires Windows NT/2k/XP/2k3 to run.
Goto :EOF

Wednesday, March 16, 2005

Perl Disk Utilization Report - Transaction Logs

Here is a Perl based subroutine I created which you can add to the Disk Utilization report script giving you an additional column listing the total amount (in gig) consumed by transaction logs in your mdbdata directory.

# Figuring out the total file size for log files located in the priv directory
use File::Find;
$logByteCount=0;
$logdir= "net use t: \\\\@Drivearray[0]\\e\$ >NULL";
system $logdir;
$logpath="\\\\@Drivearray[0]\\@Drivearray[2]\\Program Files\\Exchsrvr\\MDBDATA\\"; print "Scanning $logpath\n";
find(\&log, "t:\\program files\\exchsrvr\\mdbdata");
$gigCount=$logByteCount / 1023741824;
$gigCount=sprintf("%5.2f\n", "$gigCount");
$logdirdelete= "net use t: /d >NULL";
system $logdirdelete;
$nulldelete="del NULL";
system $nulldelete;
sub log { if ((/\.log$/) ){ my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $therest) = stat($_) or die "Unable to stat $_\n";
$logByteCount += $size;

}
}

Monday, March 14, 2005

Microsoft to Buy Groove Networks

Just came across this. The founder of Groove Networks (Ray Ozzie) also created Lotus Notes. Ozzie is going to report to Bill Gates. Though most of the article talks about Groove's integration into the Longhorn build, I look at this as good for Exchange.

Thursday, March 03, 2005

Exclude a Single Mailbox From Mailbox Manager

If you have a need to exclude the use of the global policy mailbox manager service from a single mailbox you can add the attribute through ADSI Edit through the following process:


1. Start ADSI Edit. To do so, click Start, point to Programs, point to Windows 2000 Support Tools, click Tools, and then click ADSI Edit.
2. Expand the domain naming context, and then locate the user that you want to exclude from Mailbox Manager.
3. Right-click the user, and then click Properties.
4. In the Select a property to view drop-down box, select msExchPoliciesExcluded.
5. In the Edit Attribute space, type the following attribute value:
{3B6813EC-CE89-42BA-9442-D87D4AA30DBC} NOTE: Make sure that you include the braces ({}) characters.
6. Click the Add button.
7. Click the Apply button or the OK button.Once saved, the change takes effect shortly. The Recipient Update Service must process the object before the mailbox is excluded from Mailbox Manager.

Thursday, February 24, 2005

Extending Calendar Look up in Outlook

This seems to be a common issue so I thought I'd jot down the quick fix... Outlook defaults the number of items you can view in your calendar to two months from the current date. Use the following process to update Outlook to additional months beyond two:

1. Select Tools, Options
2. Calendar Options
3. Free/Busy Options
4. Then update the Publish field number from 2 to how many months out is required.

Removing Corrupt Server Side Rules

I followed this procedure to remove corrupted server side rules that were preventing "Out of Office" automated replies from sending to internal recipients:

1. Find mdbvu32.exe in the \support\utils\i386 directory on the base Exchange 2000 cd.
2. Run mdbvu32.exe.
3. Click OK to clear the first window that pops up.
4. Make sure that your profile is selected in the Choose Profile window and click OK.
5. Click on the MDB menu option.
6. Click on the OpenMessageStore option.
7. Make sure that "Mailbox- [user's full name]" is selected and click on Open.
8. Click on the MDB menu option again.
9. Click Open Root Folder.
10. In the Child Folders box - double click on "Top of Information Store".
11. In the next Child Folders box - double click on "Inbox".
12. Look in the Associated Messages in Fld box. All of your rules are in this box.
13. Once you find the rule that you want to delete then close the properties for that rule.
14. On the MAPI_FOLDER page make sure that the rule that you want to delete is still highlighted.
15. In the "Operations available (select operation, then push Call Function button)" text box, push the drop down button to reveal the list of functions.
16. Scroll down the list of functions until you see "lpFld -> deleteMessages() (ON SELECTED MSGS)" and then click on it to select it.
17. Next press the Call Function button. This will delete the rule that you selected.
18. Press the Close button to exit the MAPI_FOLDER window.
19. Press Close again to exit the next window.
20. Press Close again to exit the last window.
21. Click on the MDB menu option.
22. Click Store Logoff. Then click OK and OK again.
23. Click Session and then click on Exit.