Work

Unable to sync while offline.

Had a weird issue with a Palm device using Activesync. The device would not synchronise when the laptop pc was working offline. This functionality was fixed/improved in Activesync 4.5 but unfortunately the device was already at this version.
Eventually we found that going to the device and selecting Start > Settings > Connections > USB to PC and remove “Enable advanced network functionality” and then doing a sync worked fine.

Performance monitor showing numbers instead of counters.

Had a weird error today with a machine only showing numbers instead of descriptions in the performance counters. Thanks to maximum asp this is solved by exporting the registry entries from hklm\ Software\ Microsoft\ WindowsNT\ CurrentVersion\ Perflib\ 009 from another machine and importing back into the affected machine. This kind of solution is great if you have another machine that you can export from – not too great if this is the only machine you have access too. If you don’t have access then “You could check the strings in the 009 key under the key described below and look for any garbled entries, entries that have two numbers, or entries that have two strings in succession (you should see ### string ### string, and so on in the multi-sz editor). This may not explain the different behavior between the local and remote cases because they both access the same registry values. (KB152153). Good luck with that!

Powershell script to retrieve email from archived mailbox in Exchange2007

The other powershell script I worked on was to retrieve a detached mailbox that was still retained in exchange, archive the mail to a pst file, move the pst file to the managers home directory and then delete the mailbox again.
The following script does this – note some paths are hardcoded and I already have a temporary account in AD called tempuser that does not have a mailbox. This is the account that the deleted mailbox is attached to.
The main disadvantage to this method is that at the end of the script all of the detached mailboxes will appear as tempuser in the exchange console. In this particular script I also do very little error checking as this was designed for my use but hopefully helps others too.


$user=$args[0] #user is the first parameter passed
$fname=$args[1] #first name
$lname=$args[2] #last name
$fullname=$fname + " " + $lname
$manager=$args[3] #manager windows accountname is the last parameter passed
if ($manager -eq $null) {exit} # if not enough parameters are provided then quit the script

write-host $user
write-host $manager
$Host.UI.RawUI.WindowTitle = "attaching mailbox to tempuser account"

$result=Connect-Mailbox -Identity $fullname -Database 'servername\First Storage Group\Standard User Mailbox' -User 'domain\tempuser' -Alias 'tempuser'

$Host.UI.RawUI.WindowTitle = "Sleeping 60 until moving mailbox"
start-sleep -s 60 # sleep 60 seconds after moving mailbox to tempuser account before doing the export

$Host.UI.RawUI.WindowTitle = "exmerging mailbox"
export-mailbox tempuser -pstfolderpath d:\mailboxes -confirm:$false

$Host.UI.RawUI.WindowTitle ="sleep 20 seconds"
start-sleep -s 20 # sleep 20 seconds after exporting mailbox to tempuser account before doing the mailbox move

$Host.UI.RawUI.WindowTitle = "Moving pst file to managers mailbox"
$newdir="\\archiveserver\c$\users\" + $manager + "\" + $user
$result=mkdir $newdir
$newpst=$newdir + "\" + $user + ".pst"
$newpst
Move tempuser.pst $newpst

$Host.UI.RawUI.WindowTitle = "disabling tempuser mailbox for reuse"
disable-mailbox tempuser -confirm:$false

Note that I use the $Host.UI.RawUI.WindowTitle statement a lot – this enables me to easily see whereabouts in the script I have got to. I much preferred to use the command title in my batch files to do the same thing. Likewise the $null = $host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) is the equivalent of the batch command pause

Powershell script to retrieve list of emails from Exchange2007 in the past 24 hours.

As in my previous post I needed to obtain a list of emails that have gone through a mail server within the past 24 hours (so it can be run on a daily basis). I struggled with the code initially but ended up with the following.

$yesterday = (get-date).adddays(-1).tostring(“g”)
$rightnow = (Get-Date).ToString(“g”)
get-messagetrackinglog -Start $Yesterday -End $rightnow -EventID RECEIVE -Result size 5000| select-object EventID,Sender,@{name=’Recipients’;expression={[string]::join(“;”,($_.Recipients))}},MessageSubject,TimeStamp | export-csv receive.csv
get-messagetrackinglog -Start $Yesterday -End $rightnow -EventID SEND -Resultsize 5000| select-object EventID,Sender,@{name=’Recipients’;expression={[string]::join(“;”,($_.Recipients))}},MessageSubject,TimeStamp | export-csv send.csv

My next step is to automate this and send it via email

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 irc.freenode.net 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.

BackupExec 12 fails to LiveUpdate on Windows 2008

When trying to run LiveUpdate from within BackupExec v12 running on Windows 2008 you may get the error message “To receive updates, Backup Exec must be registered with LiveUpdate. To automatically register now, Click Yes. If you choose not to register now, you will be prompted again when you click LiveUpdate.” The solution is to right click the BackupExec icon and run as Administrator. LiveUpdate will work.

Quick way to get BIOS information without rebooting

If you want to get the BIOS version of a pc without rebooting or the Dell service tag then use the following useful command(s)
wmic bios >c:\temp\1.txt
notepad c:\temp\1.txt

The reason I pipe to 1.txt and then display in notepad is that the formatting looks all messed up in a dos prompt due to line wrapping but looks ok in notepad. The BIOS version and service tag will be displayed (among other things).
This beats my previous preferred method when doing remote support of going to Dell’s support site, going to warranty information and then loading their activex component to detect the hardware information.
Update: You do need to have admin rights to run this command.

Group Policy preference hurdle.

I’ve been wanting to use the group policy preferences at a couple of sites but been unable to due to the fact that you need to have a Vista or Windows 2008 server in the domain. I knew that one or the other was required, but I was kind of hoping that you could get away with using a Vista machine not on the domain to edit the group policy settings. Much like you can use “connect to” in eventvwr and other mmc consoles I was hoping this feature would be available so I could take my consultants laptop and edit various group policy preferences at some of my sites without needing a domain joined pc. Alas, this is not to be – in fact gpmc is not even available unless you are joined to the domain.
Here’s hoping that some enterprising company will come up with an application that will enable you to deploy group policy preferences without Vista or Windows 2008.

70-649 passed.

Took the exam this morning – I would say this is probably one of the easier exams, especially if you are familiar with the product (well duh!) A lot of the questions have keywords in them which means that instantly you know the answer has to be this particular one. Hard to explain, but in some exams you narrow down to two possibles and then you have to reread to get the correct one – in this case, keywords in the question instantly narrowed down to 1.
The annoying/scary bit is that it’s really 3 short exams in one and your worst score counts – if you fail one section you fail the lot. Fortunately I got 100% in the first two and 970 in the last one – I think I got one question wrong. Out of all the questions there were only 3 questions I wasn’t sure about – the others I knew were correct.

70-649 exam booked.

I booked my 70-649 exam last night for next Monday which gives me the weekend to do any last minute prep work and testing. I finished my 973 pages of reading the Syngress book – The Real MCTS/MCITP Exam 70-649 Prep Kit: by Brian Posey. The book wasn’t bad but there were quite a few errors in the book. There was only one sample answer that I totally agreed with (and therefore it must be wrong 😉 but there were a couple of times where text was repeated twice due to sloppy copy/paste editing and several times words were spelt wrong or letters missing. The last chapter for example, on Network Access Protection, seemed to be short on finishing the actual testing of the NAP client and unfortunately spent more time going on about tips for the exam. I would have thought this would be better in a separate chapter and instead actually go through the steps of testing the client machine for compatibility
Anyway, the exam is booked with the second chance offer .and if I pass I’ll be able to give the book a glowing review 😉
This exam is pretty good in that it is needed to upgrade my MCSE qualification to the 2008 equivalent but also gives me 3 MCTS qualifications,