2009
11.16

Here’s a quick script for Powershell that can be used to add a secondary SMTP address in Microsoft Exchange 2007.

$username=Read-Host "Enter username to add email address too."
$secondsmtp=Read-Host "Enter a secondary email address"

$usermbx = Get-Mailbox $username
$usermbx.emailAddresses+=$secondsmtp
Set-Mailbox $usermbx -emailAddresses $usermbx.emailAddresses

2009
11.16

UPDATE: Check my next post for further info on this, and the issues it has with IE.

There are many methods for setting up IIS to redirect users to the correct site.  If a user visits http://email.contoso.com, they need to end up at https://email.contoso.com/owa.  If a user visits https://email.contoso.com, they need to end up at the same place.  This is the easiest way I could find to accomplish both tasks:

Step 1 – Force IIS to use HTTPS

Step 2 – Setup the home directory to be a redirection to a “directory below this one” and fill in /owa (use /exchange for 2003)

Step 3 – Setup a custom error page for 403.4 errors with the following code:

<html>
<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=https://email.contoso.com/exchange">
</head>

Step 4 – iisreset

All set.  Leave comments with any questions or comments!

2009
11.16

EDIT: I wrote a Powershell script to leverage this.

Recently I required a simple backup method for our virtual servers, which our guests in our Hyper-V based office development environment.  Thanks to several knowledgeable bloggers I found information on using Windows Server 2008’s VSS writer: diskshadow.exe.  This allows an administrator to mount a shadow copy like a physical drive, and copy its contents elsewhere.  There are many other functions to diskshadow, but for this implementation I haven’t delved too far into those. All of my guests are Windows Server 2003 servers with at least Service Pack 2.

Here is the script I used, which is executed using diskshadow.exe /s scriptlocation.txt

set context persistent

#this sets up a shadow copy of the E: with the name VHDs
add volume e: alias VHDs

set verbose on

#no work is done until the create command is issued
create


#this uses the %VHDs% environment variable, which contains the shadow ID
expose %VHDs% z:


#this batch file contains an xcopy command, and that's it
exec c:hyperbakcopyvhds.bat

unexpose %VHDs%
delete shadows all

The beauty of this batch file is in it’s simplicity. It doesn’t require third party backup software, just the commands executed above, along with an xcopy command. I execute this once weekly, and overwriting is fine in my case. Another layer of complexity could be added by renaming the folder when complete to name the files according to date to avoid the overwriting issue. You could also use a visual basic script to remove files older than two weeks. In that case you would need 2 times more storage capacity for backups than you need for primary storage.

2009
11.16

I’ve written a Powershell script to execute the diskshadow script I mentioned earlier, and implemented a couple of ideas I had.

This script will create full backups of Hyper-V guests while they are running.

First, this script will check to see if the destination folder has any VHDs that were backed up more than 10 days ago (since this runs every two weeks it will remove the oldest of the two backups that are stored). It then starts the diskshadow script that mounts a shadow copy of the drive storing the virtuals to another drive (the Z: in my script below). Finally, it copies the VHDs from the Z: to a folder on another drive (the destination in this case is the D:) and labels the folder by date.

Here is the main Powershell script: vhdfull.ps1

#Set Date Variables
$folderdate = get-date -uformat "%m-%d-%y"
$Now = Get-Date
$DelDate = $Now.AddDays(-10)

#Start Transcript
start-transcript -path c:vhdscripttmp.txt

#Look at destination folder and remove older backups
Get-ChildItem D:VHDBackups |Where {$_.CreationTime -le "$DelDate"}|remove-item -recurse -Verbose
remove-item c:\vsbackup\tmp2.txt

#Run diskshadow, and save log for pushing into string builder for e-mail alert
diskshadow /s c:\vhdscriptvhdshadow1.txt >> c:\vsbackuptmp2.txt

#Copy the files from the disk shadow copy.
Copy-Item Z:virtuals D:VHDBackups$folderdate -recurse -Verbose

#End Transcript
stop-transcript

#Remove Disk Shadow
diskshadow /s c:vhdscriptvhdshadow2.txt


#Create string builder to format logs
$strbuild = new-object System.Text.StringBuilder

#Add line breaks to both logs, and glue them together
foreach ($line in get-content "C:vhdscripttmp2.txt")
{
$strbuild.Append($line).Append("<br/>")
}
foreach ($line in get-content "C:vhdscripttmp.txt")
{
$strbuild.Append($line).Append("<br/>")
}

#Send it.
$message = new-object System.Net.Mail.MailMessage("VHDBackup@localhost", "support@domain.com")
$message.Subject = " - VHDBackup"
$message.IsBodyHtml = $True
$message.Body = "<font size=2 face=Arial>"+$strbuild
$smtp = new-object Net.Mail.SmtpClient("<IP OF SMTP SERVER HERE>")
$smtp.Send($message)

Here is the first diskshadow script: vhdshadow1.txt

set context persistent
add volume e: alias VHDs
set verbose on
create
expose %VHDs% z:

… and the second: vhdshadow2.txt

delete shadows all

2009
11.16

This Powershell script generates a report of all mailboxes in an organization that are larger than 100MB.  It sorts them from largest to smallest and generates a pretty HTML report to send.  Using variations of this script you could set it to only generate the first 10 “big hitters”, ignore the Custom Attribute fields (which in my situation show which company the box belongs to), or make any other change that would customize it for your environment.  If you would like any help with using this script, feel free to let me know in the comments.

I run this script once weekly using scheduled tasks.

Also, a huge thanks to Glen Scales at Glen’s Exchange Dev Blog. You will find aspects of his code in mine, and his website gave me the base for a lot of the scripts I use.

$message = new-object System.Net.Mail.MailMessage("powerlogs@domain.com", "recipient@chris.nabkey.net")
$message.IsBodyHtml = $True
$message.Subject = "Automated E-Mail Quota Report"
$smtp = new-object Net.Mail.SmtpClient("172.16.1.100")

$mbcombCollection = @()
Get-Mailbox -ResultSize Unlimited | foreach-object{
$mbstatis = get-mailboxstatistics $_.identity
$TotalSizeMB = $mbstatis.TotalItemSize.Value.ToMB()

$mbcomb = "" | select DisplayName, TotalItemSizeMB, QuotaStatus, Itemcount, Email, CompanyName

$mbcomb.DisplayName = $_.DisplayName
$mbcomb.TotalItemSizeMB = $TotalSizeMB
$mbcomb.Itemcount = $mbstatis.ItemCount
$mbcomb.QuotaStatus = $mbstatis.StorageLimitStatus
$mbcomb.Email = $_.PrimarySmtpAddress
$mbcomb.CompanyName = $_.CustomAttribute1
$mbcombCollection += $mbcomb
}

$body = $mbcombCollection | Sort-Object -descending TotalItemSizeMB | where {$_.TotalItemSizeMB -ge 100}  | convertto-html -head '<style type="text/css"> body { background-color:#EEEEEE; } body,table,td,th { font-family:Tahoma; color:Black; Font-Size:10pt } th { font-weight:bold; background-color:#CCCCCC; } td { background-color:white; } </style>'

$message.Body = $body
$smtp.Send($message)

2009
10.26

Problem:

Unable to see emails in mailbox subfolders on a Blackberry phone which is Blackberry Enterprise Activated.

Resolution:

On a Blackberry Enterprise Activated phone, to enable email subfolder redirection from the Blackberry, use the following steps on the phone:

1. From the Blackberry main menu, open Messages.

2. Press the menu button –> Options –> Email Settings

3. Press the menu button –> Folder Redirection

4. Expand the mailbox by highlighting it -> pressing the menu button –> and selecting Expand.

5. Expand the Inbox.

6. Highlight the folder you’d like to enable redirection to.

7. Press the menu button –> select Change Option

8. Press the menu button –> Save

2009
10.13

It’s about time someone started calling out trash disguised as DIY projects.

http://isthisdiy.com

2009
10.07

I ran into an issue with Pidgin where I started noticing some users weren’t showing up as online for a long period of time.  I set it to allow to send to offline contacts, and tried to send to someone I knew was online.  It gave me the error:

Unable to send message: In local permit/deny

I fixed this by blocking the user, and then unblocking him.  Hope this helps for you as well.

2009
10.06

By default, Microsoft Word 2007 may double space between lines of text in an e-mail or document.

To resolve, use the steps found on Microsoft KB921174:

1. Click the Home tab.

2. Click Change Styles in the Styles group, point to Style Set, and then click the style set that you want to use.

To change the default formatting of your document, such as the line spacing and paragraph spacing, to the default formatting that is used in earlier versions of Word, click Word 2003.

To set the style set as the default style set in Word 2007, click Change Styles in the Styles group, and then click Set as Default.

2009
10.02

When repairing a network connection in Windows XP, a user receives error stating that the operation failed because it could not clear the ARP cache.

To resolve this problem:

1. Click Start
2. Click Run
3. Type “Services.msc” –> Press Enter
4. Right click “Routing and Remote Access” –> Click Properties
5. Set the “Startup Type” drop down menu to “Manual”
6. Attempt to repair the network connection.