Exchange 2007 delete all items from mailbox

28 March, 2014
  • Grant FullAccess to the mailbox you need to blank
Get-Mailbox "target-username" | Add-MailboxPermission -AccessRights FullAccess -User "my-username"
  • Delete the content
Get-Mailbox | Export-Mailbox -DeleteContent
  • Remove FullAccess to mailboxes
Get-Mailbox "target-username" | Remove-MailboxPermission -AccessRights FullAccess -User "my-username"

From: http://community.spiceworks.com/how_to/show/892-delete-emails-in-exchange-2007

Vim copy/paste in xterm

06 September, 2009

If you find that you cannot paste into vim using middle-click from another xterm, edit your vimrc and comment out these lines:

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
  set mouse=a
endif

It seems the mouse support being on affected the usual highlight and middle-click paste functionality.

Generate BIND reverse DNS entries

14 January, 2009

I sometimes have to create rDNS entries for a particular server with a bunch of IPs -- and doing it manually isn't very much fun. The following script quickly creates entries that can be pasted into your zone file, or outputted to another file.

#!/bin/bash
# Script to generate Bind reverse DNS entries
# If no arguments, it will ask for each parameter,
# otherwise, you can you simply call it like:
# script "my description" hostname.com. startIP endIP

if [ ! "$1" ]
then
        echo -n "Enter description: "
        read desc
        echo -n "Enter hostname: "
        read host
        echo -n "Enter start IP: "
        read startip
        echo -n "Enter end IP: "
        read endip
else
        desc=$1
        host=$2
        startip=$3
        endip=$4
fi

count=$startip

echo "; $desc"
while [ $count -le $endip ]
do
        printf "%d\t%s\t%s\t%s\n" $count IN PTR $host
        count=$((count+1))
done

Example:

$ genrdns.sh "my server" myserver.com 82 90

; my server
82      IN      PTR     myserver.com
83      IN      PTR     myserver.com
84      IN      PTR     myserver.com

Expect SMTP Script

11 January, 2009

The following expect script will connect to a mailserver and attempt to send a test message. Useful for quickly troubleshooting mail issues. Usage: expect mail.exp mailserver from_address to_address

#!/usr/bin/expect
set mailserver [lrange $argv 0 0]
set from [lrange $argv 1 1]
set to [lrange $argv 2 2]

spawn telnet $mailserver 25
expect "failed" {
                send_user "$mailserver: connect failed\n"
                exit    
        } "2?? *" {
        } "4?? *"   {
                exit
        } "refused" {
                send_user "$mailserver: connect refused\n"
                exit
        } "closed" {
                send_user "$mailserver: connect closed\n"
                exit
        } timeout {
                send_user "$mailserver: connect to port 25 timeout\n"
                exit
        }
send "HELO foo.com\r"
expect "2?? *" {
} "5?? *" {
        exit
} "4?? *" {
        exit
}
send "MAIL FROM: <$from>\r"
expect "2?? *"  {
} "5?? *" {
        exit
} "4?? *" {
        exit
}
send "RCPT TO: <$to>\r"
expect "2?? *" {
} "5?? *" {
        exit
} "4?? *" {
        exit
}
send "DATA\r"
expect "3?? *" {
} "5?? *" {
        exit
} "4?? *" {
        exit
}
send "From: $from\r"
send "To: $to\r"
send "Subject: test\r"
send "This is a test message\r"
send ".\r"
expect "2?? *" {
} "5?? *" {
        exit
} "4?? *" {
        exit
}
send "QUIT\r"
exit

SVCP: Simple VHost Control Panel

11 January, 2009

SVCP: Simple VHost Control Panel

SVCP is a collection of Bash shell scripts to help simplify vhost creation and maintenance on a system that only hosts websites a small number of websites. Nothing for mail, DNS records, etc is done by these scripts. SVCP is designed for a Linux system with access to common manipulation tools (sed, awk) and running Apache.

Download:

Current version: 0.2 svcp.tar.gz

Installation:

Unpack the SVCP archive somewhere (like /opt/svcp) and either add this directory to your path, or place a symlink to the svcp file somewhere in your path.

You will need to edit the svcp file and modify the PREFIX variable to point to the directory containing the rest of the svcp scripts.

Configuration:

Edit svcp/config.sh to reflect your system's virtual hosting setup. In your main httpd.conf file, add:

Include vhost.conf.d/*.conf or your directory of choice, at the end so it will read all the vhost configuration files from that directory.

Usage:

You can run svcp followed by an action, for example:

# svcp add

which will run the svcp-add script. You can also call each of the scripts independently.

Currently, the available options are: add, del, list, update

Virtual Host Setup:

SVCP creates virtual hosts using the following schema: Username: specified on creation Group: one group common to all vhosts, specified in config.sh Document Root: /vhost_base_path/username/vhostname Logs: /vhost_base_path/username/logs

Miscellaneous:

Currently, limited error handling is done, and in particular the creation script doesn't check for much of what exists (the user, directories).