PowerShell script that gives you a random infosec job title in your Outlook signature.
permalink nebrivOriginally published on blog.benvirgilio.com
Quick and dirty fun little script that I wrote while bored.
This script does rely on an external website to pull a random security job title, so if that site no longer exists the code will break. This script will save the signature as a html file in your profile AppData\Roaming\Microsoft\Signatures
# Written by: Ben Virgilio
# Date: 6/26/2013
#
# Make sure to modify the variables below, and to select the signature from the dropdown list in Outlook!
#Set these variables to your information...obviously.
$name = "Ben Virgilio"
$department = "Systems"
$address = "100 Risk Analysis Road"
$email = "[email protected]"
$subtext = "There's no place like 127.0.0.1"
$disclaimer = "The above job title is completely randomized via powershell script (you can find it here: http://blog.benvirgilio.com/outlook-security-signaturerandomizer), it may not be relevant to what I actually do."
#Parses the random security title page and gets the first title
$p = Invoke-WebRequest "http://zeltser.com/security-titles/get-titles"
$p -match "<li>(?<content>.*)</li>" | out-null
$title = $Matches['content']
$title = $title -replace " "," "
#Sets outlook to get signatures from your AppData folder
$UserDataPath = $Env:appdata
if (test-path "HKCU:\\Software\\Microsoft\\Office\\11.0\\Common\\General") {
get-item -path HKCU:\\Software\\Microsoft\\Office\\11.0\\Common\\General | new-Itemproperty -name Signatures -value Signatures -propertytype string -force | out-null
}
if (test-path "HKCU:\\Software\\Microsoft\\Office\\12.0\\Common\\General") {
get-item -path HKCU:\\Software\\Microsoft\\Office\\12.0\\Common\\General | new-Itemproperty -name Signatures -value Signatures -propertytype string -force | out-null
}
if (test-path "HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General") {
get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General | new-Itemproperty -name Signatures -value Signatures -propertytype string -force | out-null
}
#Make the signature folder
$FolderLocation = $UserDataPath + '\\Microsoft\\Signatures'
mkdir $FolderLocation -force | out-null
$FileName = "RandomTitle"
#And finally, create the signature!
$stream = [System.IO.StreamWriter] "$FolderLocation\\$FileName.htm"
$stream.WriteLine("<!DOCTYPE HTML PUBLIC `"-//W3C//DTD HTML 4.0 Transitional//EN`">")
$stream.WriteLine("<HTML><HEAD><TITLE>Signature</TITLE>")
$stream.WriteLine("<META http-equiv=Content-Type content=`"text/html; charset=windows-1252`">")
$stream.WriteLine("<BODY>")
$stream.WriteLine("<b>$name</b>")
$stream.WriteLine("<br>$title*")
$stream.WriteLine("<br><br>$department")
$stream.WriteLine("<br>$address")
$stream.WriteLine("<br>$email")
$stream.WriteLine("<br><br>$subtext")
$stream.WriteLine("<br><br><font size=3>*</font><font size=1>$disclaimer</font>")
$stream.WriteLine("</BODY>")
$stream.WriteLine("</HTML>")
$stream.close()
Write-Host "$name your new title is now '$title' congrats!"