“Free Ice Cream” – Harmless Office Email Prank Utilizing PowerShell

Unfortunately, I was caught when trying to manually send an email today when someone left their computer unlocked.

So, next time around, I’m prepared..

$OUTLOOK = "C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE"

function generateParticipants {
    $PARTICIPANT_LIST = $args[0]

    $PARTICIPANT_STRING_TO_RETURN = ""

    foreach ($PARTICIPANT in $PARTICIPANT_LIST) {
        $PARTICIPANT_STRING_TO_RETURN = $PARTICIPANT_STRING_TO_RETURN + ";" +  $PARTICIPANT
    }

    $PARTICIPANT_STRING_TO_RETURN = $PARTICIPANT_STRING_TO_RETURN + ";" + $PERSON_EMAIL

    return $PARTICIPANT_STRING_TO_RETURN
}

function createEmail {
    $SUBJECT = $args[0]
    
    $BODY = $args[1]
    
    $TO_ARRAY = $args[2]

    $TO = generateParticipants $TO_ARRAY

    $MEETING_CONTENTS = "$TO&subject=$SUBJECT&body=$BODY"

    Start-Process -WindowStyle Maximized -FilePath "$OUTLOOK" -ArgumentList "/c  ipm.note /m `"$MEETING_CONTENTS`""
}

$EMAIL_SUBJECT = "Free Ice Cream!"
$EMAIL_BODY = "I'm Buying."

$PARTICIPANT_LIST = New-Object Collections.Generic.List[String]

$PARTICIPANT_LIST.Add("person1@company.com")
$PARTICIPANT_LIST.Add("person2@company.com")
$PARTICIPANT_LIST.Add("person3@company.com")

createEmail $EMAIL_SUBJECT $EMAIL_BODY $PARTICIPANT_LIST

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s