Pimp your Powershell Prompt

I use powershell a lot at work – I’m not a guru by any means and I often find it hard to remember the commands I have run in a session, either for future use or for documenting in my time sheet (which also acts as a point of reference for future helpdesk tickets).

When I started going through the Powershell in a month of lunches book (which I highly recommend or the Powershell v3 book) I decided to use the start-transcript commandlet to record all my powershell activities.  This worked very well until I would scroll through several screens worth and then forget what file I had saved my transcript too.  There was also the possibility of forgetting to transcript everything.

By using the powershell profile file I was able to enter the commands to automatically set the transcript to the current date. I was then able to modify the title of the powershell prompt to display the filename so I could always see where the file was saved with the added bonus of a variable being used if I ever needed to open the transcript

My next step was to include the time in the powershell prompt – this enables me to go back through the transcript and see how long it took to run the commands for my timesheet entries.  Remembering back to the good old dos days, I remembered the prompt command. A quick bit of experimenting with the Date command I had the current time displayed at the beginning on the Powershell prompt. Note this is displayed after the previous command is run, so technically it’s not the exact current time, but the time that the prompt was displayed on the screen.

The final profile script can be copy/pasted into notepad by typing in

notepad $profile

is as follows:-

cd \andy\powershellinamonthoflunches

$log="c:\temp\powershelllogs-" + $env.username + (get-date -uformat "%y%m%d-%H%M") + ".txt"
start-transcript $log
$host.ui.rawui.WindowTitle = $log

function prompt
{
write-host ((Date -uformat %T).ToString() + "PS " +$(get-location) + ">") -nonewline
return " "
}

This ends up with a powershell prompt that looks like the following. Hope this brief posting inspires you to change your powershell prompt to be even more useful for you.

 

Powershell prompt with the filename in the title and current time in the prompt

 

Fixed – Office365 journalling does not work for one user

I’ve been working on a case with Microsoft’s Office365 support for several weeks trying to find out why email sent *to* a particular user was not being journalled. All the other mail seemed to be journalled to the external recipient, email from the user was working, just not email to that user.

The experience was quite frustrating as Microsoft’s support were terrible at calling back and could not grasp the concept of email tracking. Their solution after making a change was to wait a day to see if it was fixed although it was quite apparent that the Microsoft servers were not even trying to send the email (by looking at the Trace Logs you can see what email was being sent and received).

After checking the connectors were setup, mail properly scoped, the user had no rules on their mailbox, Microsoft’s solution was to delete the mailbox and reset it up again.  Not so easy when the mailbox/user is federated with Active Directory and the user happens to be the owner of the company. That was not a conversation I was going to have with them!

The only thing that was different with this user was that in troubleshooting this issue we had set the user up to receive the journalling non delivery reports. I figured that if the emails were not being delivered, maybe sending him the errors would help. However no reports were being received either.  However, according to KB 2829319 this behaviour can be seen. Although I had removed the journal receipient in the web gui, the emails were still not being journalled until I added another external email address to the configuration using the powershell command set-transportconfig -JournalingReportNdrTo [email protected]

At this point, all the email started to be journalled.

Note that we only added the recipient into the mix when I was trying to work on the initial problem so it looks like this wasn’t the only fix.

The other thing we did was change the outboundconnector to be onpremises. Changing the setting in the GUI we then ran Set-OutboundConnector archivemymailconnector -routeAllmessagesviaonpremises $true.

 

These two combinations seemed to fix the issue.

One thing I also learnt was that it is really useful to send multiple emails between changes and keep the subject line starting the same. Use the date/time at the end of the email. That way you can sort the email logs by Subject and just pick out the ones you were working on. By having the subject start with zzz followed by Round X (ie zzz Round 1 – change connector – 1345pm and zzz Round 1 – change connector 1346pm ) then the results are likely to appear at the end of your mail logs if you sort by subject.  Sorting by Date was not always a good idea as mail flow could occur between mail coming into the server and mail leaving the server.

 

Fixed: Office 2010 installation with MAK key gives Error: Can’t decode PIDKey – Invalid digits! ErrorCode: 0(0x0)

After doing an administrative installation of Office Professional Plus 2010 for a client, I was trying to test the installation of office on a desktop machine but kept getting “Error: Can’t decode PIDKey – Invalid digits! ErrorCode: 0(0x0).” as the error message. I confirmed that the key was correct by doing a manual installation of the software and using the same product key that was successful. I was unable to find any useful pages on the internet with this error message so ended up logging a call with Microsoft Product Support to troubleshoot the installation.

Our troubleshooting steps were to remove the updates folder completely and try an installation – this worked so we knew the problem was in the updates directory. Recopying back the files from the extracted service pack 1 dvd worked successfully so the problem was either service pack 2 or the setup.msp file. I copied back the sp2 files and again the software installed successfully (note that having a virtual test pc makes these tests very easy. No uninstalling of office required!)  Again the installation was successful. I then copied the setup.msp file back into the updates directory and the installation failed again. As the configurations that are made in the setup.msp can either be set in the config.xml or group policy it was ok to proceed without using the setup.msp.

Full details of the log files and more information can also be found at the Microsoft forums where I posted the initial request for help.

Would/Should you block linkedin to your Exchange Server?

Apparently Linkedin now have a feature that allows users to provide their corporate passwords to a third party so the users can then send invites to other people in their office.  I really don’t see how this can Be A Good Thing 😉 – Paul Cunningham has a post on ExchangeServerPro on this feature and links to Adam Fowler’s post on how to block LinkedIn to Exchange. This is interesting as we’ve also seen this issue with Verizon doing something that we expect is screenscraping to provide email information to phones. Admittedly this was a while back but we have found it hitting the Exchange server so it will be interesting to see if this successfully blocks the server.

In a meantime, maybe it’s time to not only educate LinkedIn that this is a really bad idea but also your corporate users.

For what it’s worth the solution is to do the following:-

There are a few settings to check. First, under the Set-OrganizationConfig area, you’ll need to check that EwsApplicationAccessPolicy is set to ‘EnforceBlockList’. If it’s not, it’s going to be “EnforceAllowList” and you’re probably OK, as it’s using a whitelist for access to only what’s listed rather than a blacklist, to only block what’s listed.

Next, you need to add LinkedIn into the BlockList. This is done with the command “Set-OrganizationConfig -EwsBlockList LinkedInEWS

Sometimes it’s nice to see Microsoft add my information to their knowledge base.

This morning I was working on a Sites and Services issue for a client and part of the troubleshooting process was to run the Best Practice Analyzer on the domain controller. One of the results was to enable client fallback to the local netlogon and sysvol share after the local domain controller comes back online again. This reduces traffic across the network. I’m not quite sure why this is not enabled by default.

The BPA points to the technet article DFS-N: Client failback should be enabled for the Netlogon and SYSVOL folders on domain controllers.  Scrolling through the page I was pleasantly surprised to see my avatar at the bottom with a comment on improving the documentation with the actual registry keys that needed changing. Not only was my comment on the page, the original web page had been updated to include the information.

It’s nice to see content updated based on user feedback. It’s not nice to see that I had this problem 3 years ago 😉

Fixed: Facebook update constantly downloading and google play not working afterwards.

Last week my mobile phone started to constantly download a Facebook update which was draining the battery due to the constant downloading attempts. Trying to stop the download, I somehow managed to disable the download manager – this did fix the problem but for some reason also stops the Google play store from working. Every time I opened Google Play the application would just disappear from the screen. There was no forced close error message.  This was a bit of a problem as I had removed the Facebook app from my phone trying to stop the download and then was unable to reinstall it as the store would not open.

To fix this issue, Open Settings, Application Manager, scroll to All applications and then scroll down to the bottom of the screen. It is necessary to scroll all the way down as the disabled applications are at the bottom of the alphabetical list. Click on Downloads and then enable the application.

The app store will then start working and hopefully you won’t get the facebook update pushed down to your phone (I didn’t at least)

Trying to install System Center 2012

I have been battling this install for 2 days so far and not getting anywhere. There are a ton of sql prerequisites and the install error messages are very vague, like this message below:-IF
Surely it can’t be that hard to display the version of SQL server that is detected.

I’m currently following Harold Wong’s System Center install guide along with Matthew Peter’s guide and downloaded the Cumulative update 10 for SQL.
Attempting to install this patch on the server gives the error message below.
Screenshot - 1_3_2013 , 11_56_37 AM

The stupid thing about this is that neither 10.51.2500.0 or 10.1.2531.0 are valid sql version numbers. Select @@version returns the accurate 10.50.2500.0 which is sql 2008 r2 sp1 but it ignores the previous cumalative update that I’ve already installed.

So far my hopes for System Center have been severely dashed and buried in the ground. It’s a good job we don’t have windows in this office or I’d be tempted to set fire to the server and chuck them out of the window.

It’s been a long start to the new year.

 

Spammotel going paid.

Years ago I came across Spammotel.com – a useful service that would generate random looking email address’s and then allow you to receive emails sent to those email address’s at your real address. A useful third party system that would allow you to quickly and easily change the destination of where the emails go and also block people who abused the address by deleting the address. In the past I had several email lists that go to my Spammotel and then are redirected to my work email address – when I changed jobs, I only had one location to change my email address and all the emails started coming into the new mail account. (This was before RSS feeds to allow you to go grab the content when convenient as opposed to having it delivered via email).
They have now decided to go pro only and charge $9.99 a year for the service – still not bad, but to be honest, it’s probably better to get a domain of your own and set up catch all email address’s and then dev/null any that get abused. That might sound a bit complicated for some users, but most people reading this blog will know what I’m on about.
Ironically, the email announcement about this change in service when to my Gmail spam folder and my corporate Postini filter.
I’ll be checking the web site to see which of my to see what email lists are active and see if I need to resubscribe to any (the list gives you the number of emails received which is a nice function).

Fixed: bootshieldsvc and offline files disabled after a reboot for Lenovo machines)

For the short answer go here.
For those of you that follow me on Facebook, you may have seen my frustration with Microsoft support. I had to log a support call with their support as every time my computer rebooted, offline files were disabled. Unfortunately the technician attempting to support me obviously had no idea of what offline files were or even how to create a new user account in Windows7 (to troubleshoot if it was my account or not that was causing the problem). At no point in time did either of the 3 techs look at the event log, despite me trying to tell them there was issues reported in the log.
To cut a very long and frustrating story short, I initially followed the diagnostic steps at Jonathan’s blog and the follow up post but the setting was still disabled after a reboot. I did find that enabling the offline files service from disabled (or manual) and then starting the service, the offline files were temporarily enabled.
As part of this troubleshooting step, the issue was obviously something resetting the services on startup so off to the eventlogs. The Offline Event Logs section had nothing in it out of the ordinary but my Application log was full of Bootshieldsvc errors. One “offline files bootshieldsvc” search later
shows this is a known problem with Lenovo’s rapid boot software. The Rapidshield patch from Lenovo was downloaded, extracted, installed and the pc rebooted and sure enough offline files was STILL not enabled. Urgh.
clicking start, and entering RapidBoot confirms the version is 1.23 and the gui has an option to disable the feature. This requires a reboot so I used the opportunity to re-enable offline files again and rebooted – STILL disabled. After another reboot, just to be sure Offline files was still disabled. Checking RapidShield Gui, the software claims it is not running, but checking the application log after a reboot still shows the various errors – for example Event 256 for BootShieldsvc – “An error has occured (—query FLAG_AUTO_SVC_CHANGED key success failed with 1,The Code is:0x24.).
Apart from the fact that there is a “success failed” – it’s really not encouraging that software is still running and making changes despite it being disabled. Next stop was an uninstall (and enabling offline files again) followed by yet another reboot. It’s a good thing this machine is fast at rebooting.
So after uninstalling – the problem still occurs – arghhhhhhhh.
Checking the status of the Offline Files service I noticed it was still set to manual. Comparing against another machine where offline files works, the service should be set to automatic. I changed the service to automatic and started. Offline files was now showing it was enabled. Another reboot and the service was back to manual again and offline files disabled – more arghhhhhhhhhhh
Next stop is to try and hack out the Fast Boot Service of Lenovo. UNfortunately I get access denied when trying to stop the service. msconfig stops the service but it still somehow manages to try and make changes as evidenced by the events in the eventlog after a reboot.
sc delete “BootShieldSvc” from an elevated command line also removes the service but it comes back after a reboot. After a reboot into safe mode I was able to disable the Fast Boot Service of Lenovo, set the Offline Files to be automatic and now offline files works.

In Summary –
Uninstall the Lenovo Rapidshield software (or upgrade).
If that fails – boot into safe mode, disable Fast Boot Service of Lenovo, Set Offline Files to automatic.

Fixed: Firefox Autocomplete address bar is empty – disable the Delicious plugin

During the past week my Firefox (v16.0) Autocomplete drop down box has had missing text appear when I start typing in the address bar as seen in the screenshot below.
Firefox autocomplete address has missing text in the drop down.
Initially I thought it was Firefox using up too much memory, but the problem occurred on all of my machines even after a recent reboot so some troubleshooting was required.
After restarting Firefox in safe mode (Click the firefox button, choose Help, Restart with add-ons disabled) I confirmed it was a problem with one of my extensions. It took several minutes to disable half the addons and see if the problem continued and then repeat the process until I could work out the offending solution.
It turns out it was the Delicious addon (v3.2.1). Disabling this I have a drop down box with url’s that I can see. The proper behaviour is shown below. The A’s are greyed out as that is the character I typed to start the autocomplete sequence off.
All Autocomplete details shown with Delicious addon disabled
With only this extension enabled I get the problem so it’s not a combination of extensions having problems. I have reported this extension as incompatible.