Twitter helped me with powershell this week.

This week at work I’ve been doing a fair amount of work with powershell. It has been a slow process as I’ve had no training in powershell and was basically teaching myself as I went along. I had two goals in mind.

The first was to automatically attach a mailbox to a temporary account, export the mail within this mailbox to a pst file, move the pst file to a folder and then delete the account again.  As Exchange2007 needs to use powershell to export the data I had to change my user deletion script to run within powershell.

My other goal was to write a report for all mail sent or received through the exchange server in the past 24 hours. Using the exchange tracking logs I was able to pull the information required to do this.

The second problem was causing me more hassles  as I could not work out how to retrieve the time from 1 day ago AND have the result in the format needed for the next part of the script. I could get the current time in the correct format OR I could get the time from 1 day ago but not in the current format. I went onto the #powershell room on but it looked like everyone was asleep as I didn’t get any response to my query.  I decided to post a tweet on twitter about the problem and within 5 minutes I had about 3 or 4 responses which was great. At the same time I also got a response in the chatroom. As usual with coding, there are several ways to get an answer.  However Jaykul was very helpful in telling me that “get-date (get-date).addays(-1) -f g”  is 2 ten thousandths of a second quicker than “[datetime]::now.adddays(-1).tostring(“g”)”
Best way to get the Time from 24 hours ago.
Now you can probably see why I was confused and struggling to get the code working!

I’m going to post the resulting code in the next posts to make it easier to search on.

Visual Studio standard 2005 arrives.

My $10 copy of Visual Studio standard 2005 came in the post today – I took the two required webcasts ages ago and when I went to check the status of my registration I couldn’t find any documentation but the funny thing is that the next day I got an email to say the product was on the way. I’m quite eager to get started on the programming – it will be interesting to see how much has changed. The last serious programming I did was with VB6 – I started off with VB3, but I did a bit of programming 2 years ago whilst looking for a job, so to get a full copy of Visual Studio for free (plus $10 shipping) and two hours of my time was a bargain. There is still time to register for this offer yourself at the VB upgrade labcast webpage. I know you can already download the express versions of the software, but this is more complete for the home programmer, but a feature comparison chart should help you decide if you want to go for this product (the list price is $249 at amazon)