So in a post that has NOTHING to do with anything else I’ve posted on here, I thought I’d share a piece of PowerShell/Exchange scripting I ended up writing for work.  I’ll update this post as I make changes, but here’s the code.  Feel free to use or modify as needed.  Please note this was written in PowerShell 1, and if you destroy your exchange implementation fiddling around with this, I take 0 responsibility.

Step 1:

Make a batch file.  This file will be used so that you can easily execute your script, or use Windows Task Scheduling to automate when this script is run.  To do this just open a text editor and save a file with the .bat extension.  You will want one line inside of the file as follows

PowerShell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1″ -Command “c:\mv2.ps1″

Please note that I’m using mv2.ps1 as my actual PowerShell file, you should change this path to point to wherever you’re saving the powershell file itself.

2) Make the powershell file!  You can just do another notepad file and save it with whatever name you use in the batch file.  Then paste the contents as below, with whatever appropriate edits

#The AddBreaks Function will format each user’s emails and present them in readable/HTML format
function AddBreak($MessageLog){
$MessageBody = “<table cellpadding=’4′><tr><td><b>Timestamp</b></td><td width=500><b>MessageSubject</b></td><td><b>Recipients</b></td></tr>”

forEach($rowItem in $MessageLog){
$MessageBody = $MessageBody + “<tr>”
$MessageBody = $MessageBody + “<td>” + $rowItem.Timestamp + “</td>”
$MessageBody = $MessageBody + “<td>” + $rowItem.MessageSubject + “</td>”
$MessageBody = $MessageBody + “<td>” + $rowItem.Recipients + “</td>”
$MessageBody = $MessageBody + “</tr>”
}
$MessageBody = $MessageBody + “</table>”
$MessageBody | out-file c:\temp.txt -append
$MessageBody = “”
}

#The Start and End variables set the period of this report, currently this displays the previous day
$MessageBody = “”
$Start = (Get-Date -Hour 00 -Minute 00 -Second 00).AddDays(-1)
$End = (Get-Date -Hour 23 -Minute 59 -Second 59).AddDays(-1)

$sender = “youremailaddress@email.com”
$recipient = “recipientemailaddress@email.com”
$CC = “ccifneeded@email.com”
$BCC = “bccifneeded@email.com”
$mailserver = “localhost”
$subject = “Email Report for $Start”
#This above block sets the email header and should be changed as required.

“<h1>Email Usage Report</h1>Please send all problems or new user requests to youremailaddress@email.com.  <br><br>” | out-file c:\temp.txt

#Complete one of these blocks for each individual you wish to have included in the report
“<br>User One<b>Sent</b> Messages: <br>” |  out-file c:\temp.txt -append
$User1Sent = get-messagetrackinglog -Sender “user.one@email.com” -EventID “SEND” -Start $Start -End $End | select Timestamp, MessageSubject,@{n=”Recipients”;e={[string]::join(“,”,$_.recipients)}}
AddBreak($User1Sent)

“<br>User One <b>Received</b> Messages: <br>” |  out-file c:\temp.txt -append
$User1Received = get-messagetrackinglog -Sender “user.one@email.com” -EventID “RECEIVE” -Start $Start -End $End | select Timestamp, MessageSubject,@{n=”Recipients”;e={[string]::join(“,”,$_.recipients)}}
AddBreak($User1Received)
#Be sure to increment the user counter and use new variables for each user.

“<br>User Two<b>Sent</b> Messages: <br>” |  out-file c:\temp.txt -append
$User2Sent = get-messagetrackinglog -Sender “user.two@email.com” -EventID “SEND” -Start $Start -End $End | select Timestamp, MessageSubject,@{n=”Recipients”;e={[string]::join(“,”,$_.recipients)}}
AddBreak($User2Sent)

“<br>User Two <b>Received</b> Messages: <br>” |  out-file c:\temp.txt -append
$User2Received = get-messagetrackinglog -Sender “user.two@email.com” -EventID “RECEIVE” -Start $Start -End $End | select Timestamp, MessageSubject,@{n=”Recipients”;e={[string]::join(“,”,$_.recipients)}}
AddBreak($User2Received)
#Here’s an example block of a second user’s email being added.  Add as many of these blocks as you need

$body = get-content c:\temp.txt
$msg = new-object System.Net.Mail.MailMessage $sender, $recipient, $subject, $body
#Uncomment the line below if you want to use attachments
#$attachment = new-object System.Net.Mail.Attachment c:\temp5.csv
$msg.CC.Add($CC)
#$msg.BCC.Add($BCC)
#Uncomment the line below if you wish to use attachments
#$msg.Attachments.Add($attachment)
$msg.IsBodyHTML = $true
$client = new-object System.Net.Mail.SmtpClient $mailserver
$client.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$client.Send($msg)

3) The above script uses a text file to parse all this information, just  create an empty text file in a location you have write access to.  The above script uses c:\temp.txt

4) You can just run the batch file to test that everything’s working, or use Windows Task Scheduler to set this up to run on a daily basis.

5) Leave a comment here if this helps!  I hacked together this code from a ton of places, with a ton of people’s help.  I hope if you have success or improvements you’ll let me know and hopefully this helps make some people’s life easier.

Tags: , , , , , ,

Posted by admin - 03/06/10 - 0 comments

 

So after like a year of not having a car or any real keys, the day is finally upon us.  I now have a big ass Cadillac.  I’m still on the prowl for good names for it, but so far I’m totally happy with the purchase.  Ask me again in 24 hours though… who knows by then I might be wanting to claw out my eyes from issues I’m having.  I need to go to the DMV sometime in the near future and see about actually transfering the title… I suppose there’s a chance right now that I get pulled over by the cops at gunpoint for driving a stolen car.  And I need to check in the trunk for body parts, but so far, so good!

Ghost-Name the Whip

Ghost-Name the Whip

Name Ideas?

Tags: , ,

Posted by admin - 01/05/09 - 3 comments

 

I don’t remember our last

It wasn’t our first kiss, and neither exactly was it our last.
It was a parking lot Passion Play
and after arriving I leaned in for a kiss
and with a coy smile you deftly avoided me, edging out of the car and telling me to wait.

I’ve never been good at following directions.

I hit you with my best smiles, lines and rhymes hoping to taste that…
sweettumblingjumbleofeffervescentflavorsandfeelingemotionsand(void)electricity

whatever it is… when I press my lips to yours.

And you dart away again, your playful smile fading into a stubborn one, telling me again to wait.

Clearly you have some plan or ploy, to heighten my desire for your lips and it works.  One of those ridiculous arguments later, a short skirmish over love’s

less discussed lessons.

Thinking back i can’t decide if it’s ugly or beautiful that one of our last moments together was arguing about a kiss.

And then we fell into that happy stride, you had a coy, aloof little smile and gave me those telling, burning looks, letting me know to be patient.

And I haltingly, grudgingly, and notwantingly was patient.

I was patient as life happened.

I was patient as second thoughts happened.

I was patient when the phone call didn’t come.

I was patient when you told me love had faded.

I don’t remember the last time we smashed the universe into its component pieces and realigned the stars in a myopic collection of feelings and bright lights, the future blasted so far beyond that only brief spots on my retinas remind me that it was ever there at all.  And having that transcendent moment of self when the world slows and narrows to one, beautiful and tantalizing moment that seems to last forever yet has that horrible distant twinge that no matter how long we stay in a universe of dazed bliss at some point eyes will open and the moment will end, and a follow up kiss to remind my subconscious you haven’t gone far and heaven’s only so far away.

I remember kissing you but I don’t remember our last kiss.
I remember when you wouldn’t kiss me but wanted to.
I remember and hope I never forget
love’s less discussed lessons

Tags: , , ,

Posted by admin - 02/04/09 - 2 comments

 

So I had a really weird weekend. On Friday night I got a late ride out to the Orange Line station, then cruised it in to hang out with Manu for the night. It was a good night, I got to check out the Roberto Alomar show and catch up with Todd, Gian, Scott, Will and Kevin. It was nice to see all those improvy folk again, and afterwards I met up with Manu for some Gyros and then we watched a new episode of Monk and Psyche. Monk was good, Psyche, as usual, was awesome. It’s up there on my list of great TV shows worth watching. I passed out on Manu’s couch mildly drunk, and mildly hookah buzzed. Happy times.

The following day we woke up late and Manu headed to Agoura to finish working on his new coffee table he’s building, and I wandered around Glendale looking for Gamers. At some point I actually almost died, I was talking or texting to Christian, I forget which, and suddenly the minivan at the crosswalk I was crossing, infront of me, began to rev its engine. I paused and looked curiously at the guy driving the thing, and he had a look of horror on his face, and suddenly he just lurched out into the middle of oncoming traffic. Had I not stopped walking, I would have gotten obliterated. Miraculously, he somehow avoided getting mauled by oncoming traffic and either decided he wanted to live or regained control of his vehicle. Then I hung out for game stuff and Frank Romeo gave me a ride into Santa Monica on Saturday night.

After checking my online bank balance and discovering that I had exactly 10 dollars to my name I knew the rest had to be calculated carefully. I got some Coffee from some VERY unhappy to be serving me waitresses at the Dennys off of Lincon, which I highly recommend you never go to, and then after about an hour or so, left there, walked around for a bit, then walked into the Norms, right across the street, for some more coffee and some pancakes. I then stumbled out of the Norms and my hoboness truly kicked in.

First I’ve been deathly ill the past several weeks, secondly, I drank like 16 cups of coffe, and third, when I’ve been sick, going from warm comfy temperatures to cold ones literally make me gag. I have no clue why, but there I was, stumbling down Santa Monica Blvd at 6 AM, coughing and occasionally leaning over to Ralph, wearing an oversized huge green jacket and carrying a hugely oversized knapsack with a buncha junk in it. I truly felt as though I had transcended into devine hobo-tude.

I made it down to the Santa Monica Pier, and wandered there for a while. It’s REALLY cool at 6:30 because it’s still dark and just starting to get light, so there’s no one around, and all the lights are still on. It gives a very cool and kindof abandoned look to everything. Then at the end of the pier I got to just sit and listen to the waves and sealions and look at the moon reflecting off of very still, very dark water. It was pretty awesome. There were also some weird art students or who knows what setting up crosses in the sand. There were a bazillion of them.

When I had sortof nodded off a bit, sitting at the end of the pier and listening to the waves, and some guy randomly wandered up and started eyeballing me, my hobo-senses told me it was time to move on, so I left the bench I was on which he immediatly laid down on, and headed down onto the beach itself. It was pretty awesome walking the beach in the pre-dawn, and there were actually a fair number of people sacked out along the beach (there was a tent, and maybe 5-7 people within a mile of the pier to the north). I wandered along and stopped into the men’s room which was pretty much the most horrifying part of the whole ordeal. Mostly because there were a bunch of stalls with no doors on them and little concrete walls. It looked like some sort of horrible POW camp bathroom. I just took a leak and headed down to the beach (hey I’d been standing near the ocean for HOURS… what do you want from me?)

Then I just threw out the towel I had gotten from Fromeo, laid down with my head on my bag and went to sleep. It was pretty warm, the sound of the water was relaxing and there wasn’t anyone there to bother me. Then as the sun came up I warmed up more and drifted in and out of sleep as people jogged or trundled by in the early morning. Hands down the best part was when I noticed someone walk up the beach wearing black jeans which were soaking wet, carrying his shoes and wearing a backpack with no shirt. The guy was in his mid 50′s and he wandered over towards me. I had a hat and sunglasses on but aparently he still managed to figure out I was awake, or was just super creepy, because he walked up and stood about 3 feet to my left.

After a few moments he looked down at me and said “I am from Russian”

To which I replied “Oh”

He looked at me for a moment and said “They Bite?”

I looked at him curiously for a moment, then he took his right arm and clamped it down on his left in the universal sign for ‘shark attack’ I suppose.

“What?”

“They bite?” he asks, making the same motion and pointing towards the ocean.

I grudgingly sit up to see what the hell the guy is talking about, and right there, about 10 feet from the shore, are a trio of dolphins splashing around. We watched them for a bit and looked at me again and said a word in Russian which I assumed to be ‘shark’ and he made the motion again and asked “They Bite?”

Aparently my hoboness had translated into ‘Sea Sage’. I shook my head at him “No dude, they’re dolphins. They don’t bite” I shook my head no and made the bite sign. “They dont bite… they’re dolphins”

He was quiet for a moment, watching them, then he repeated “Dolphin” with a crazy thick Russian accent and I nodded and he nodded. So he dropped his backpack, dropped his pants, and clad in the smallest speedo I’ve ever seen, and I played Water Polo in High School, he ran out and splashed into the water. I watched dumbfounded as the dolphins swam off, and he stood there knee high in the water for a bit and then came back, collected his pants and went on his way.

I went back to sleep again, and then the planet said ‘Hey, it’s time to wake up’ by way of sending a crashing wave of water cascading up my legs. I managed to save my bag and the computer inside but my towel and feet got soaked, so I carried around a soaking wet towel for the rest of the day. Yum.

I then wandered down Venice Boulevard, taking in the sights. I sat at the world famous muscle beach for a while and lamented how downhill THAT project has gone. Watched the crazy mind blasted nutjobs and crazy old drunks wander around, and eventually made my way over to Davy’s place where I crashed for a few nights. All in all, it was an awesome, if not discordian, experience, and I totally earned my hobo-merit badge.

Tags: , , , ,

Posted by admin - 13/01/09 - 0 comments

 

So there I was, holding fire.

Let me back up.

I decided to make myself some dinner. I had this box of spaghetti from 1943 that said “Support your troops: Buy War Bonds” on it, but my mom ensured me that spaghetti does not, in fact, go bad. So I thanked her for suffering through a retarded phone conversation with me then got to work. I cooked up the spaghetti in one pot and some delicious turkey in the other to mix with my canned Ragu.

One obvious problem. I had defrosted the turkey by putting it in the fridge some hours previous which, in fact, did nothing to defrost the turkey. So after hacking and tearing it to pieces I managed to cut off a good enough chunk of ground turkey to cook. Next step… cooking it. At my grandma’s house I’m living at now I don’t know where everything is, but eventually I found some extra virgin olive oil and was minorly foiled as it had a cork for a topper (normally I fill the cap with oil, pour and go), so I poured a bit too much, started it a-sizzling and then dropped in the turkey.

Well it turns out olive oil is flamable, and some must have splashed over the side because I blinked and then the whole stove was full of fire and I went “Dizam!” And grabbed it. I started for the sink when I looked down and paused, realizing I was holding the very short handle to a pot spewing flames in every direction, and I couldnt help but remember that oil tends to explode and splatter when hot.

So there I was, holding fire.

I probably didn’t actually pause all that long before tossing the pan in the sink, using water to put out the fire, then putting the turkey back on (and eating a delish meal).

My only concern then was if I undercooked the Turkey or not but eh, whatcha gunna do? Eating raw Turkey can’t be bad for you right?

(Before everyone chimes in to tell me that Turkey has Salmonella, I looked that up to… but Im still alive so I think I’m fine)

Moral of the Story: Nathan’s an idiot.

Tags: , , ,

Posted by admin - 06/03/08 - 0 comments

 

So… I woke up this morning to discover that I was on the Front Page of the LA Times. No joke. Thats a pretty weird experience. I knew some dude from the LA times had taken my picture but I CERTAINLY didnt expect to be on the front page, let alone wearing…

MY RAPTORS AWAY! tshirt. yeah! Anyways it’s pretty cool, and for those of you who want a peek (at the shirt) feel free to visit:

The LA Times Print Website For today (Dec. 24th)’s issue, you need the PDF of the front page on the right hand side.

I had to look up what a “Buss” is. P.s. dont worry, Im not in jail… do they have internet in prison?

P.s. Merry Christmas

Tags: , ,

Posted by admin - 24/12/05 - 0 comments