Must have Powershell snippets

Over the last few months my colleague Jon has been providing me with some very useful Powershell snippets which I thought I’d share. A number of them require the Quest ActiveRoles Management Shell for Active Directory

Display Group memberships for a user.

(Get-QADUser username).MemberOf

Display the members of an Active Directory Group

Get-QADGroupMember "Groupname" | ft name,displayname -a

Bulk remove machine from Windows DNS

The text file contains a list on NetBios machine names.

gc computers.txt | %{dnscmd dnsservername /RecordDelete campus.ncl.ac.uk "$_" A}

Recuse through a Directory Structure and delete all file with a Creation date > 90 days.

The text file contains a list of UNC paths.

GC filecontainingpaths.txt | %{dir $_ -recurse | ?{!$_.psiscontainer -and $_.creationtime -lt ((get-date).adddays(-90))} | del -whatif}

First Look at Office 2010

If you’re looking forward to the release of Office 2010 next summer (and let’s face it, who isn’t?!), then you probably already know about the availability of the public beta. If you’ve tried it, then it would be great if you could share your favourite features in the comments for others to share in your experience.

My personal favourite feature (so far – there are some things that I’m looking forward to trying in Outlook in conjunction with Exchange 2010, when we have that running) is the Backstage view in all the applications. This is the bit that you access via the “Office Button” in Office 2007, which is now accessed through a coloured “File” tab next to the ribbon’s default “Home” tab.

What I particularly like about Backstage is that they’ve brought the live-preview that was such a good addition in Office 2007 to the Print dialogue. You no longer have to look at print settings and print preview separately as they sit side by side. When you make a change to the setting, you see it reflected in the preview immediately. It makes formatting your printouts much more straight forward and will benefit pretty much everyone who uses Office.

I’ve been using Office 2010 since early on in the Technical Preview stage, before the Beta, but even so I haven’t come across all the tweaks in these new versions on the applications, so I was pleased to see that Microsoft Press have released a free ebook “First Look: Microsoft Office 2010”. At that price it’s a no-brainer to download it!

First Look: Microsoft Office 2010

How Item Count Impacts Outlook Performance

Apologies for the dry nature of this blog post, but I thought it important to give some background on why Outlook and more importantly Exchange often suffer performance issues. One of the main causes of poor performance is a user having high item counts in ‘Critical Path’ Outlook Folders and how Exchange deals with that.

Microsoft’s recommendations for Exchange 2007 are as follows:

“Ideally, it is best to keep the Inbox and Sent Items folders less than 20,000 items, and the Contacts and Calendar item counts less than 5,000. Even when maintaining item counts that are at or under the recommended maximum values, there are some operations which may still take noticeable time (usually this is approximately one minute). These operations include new sort orders and selecting folders for the first time. First time views of a folder can take even more time to generate the view. High item counts in critical path folders have an adverse effect on server performance because they are the most frequently accessed folders in a user’s mailbox. Other folders, especially custom folders that are created by end-users, can handle having larger numbers of items without having an adverse effect on the user experience because they are accessed less frequently. Be aware that, although the performance effect of having higher item counts in less frequently accessed folders is reduced, high item counts in these folders can still present intermittent performance issues as the number of folders like this increases, and the number of active users on the server increases.”
Source: http://technet.microsoft.com/en-us/library/cc535025%28EXCHG.80%29.aspx

It is important to note that not only the user with high items counts will suffer a performance hit, but also all other users on the server.

Microsoft are keen to address this problem with Exchange 2010, they are changing their recommended maximum limits to 100,000 items. This is mainly due to big improvements in disk I/O performance and larger memory caches.

Other ways to address the performance issues are to use Cached Exchange Mode. This passes the performance required to the client computer, from the server. All of the views, searches, sorts etc. take place on the Cached Mode’s OST file. Of course, this is not the answer for everybody and should the mailbox have a massive amount of items and the OST file also be massive, then the user will still experience performance issues.

Housekeeping is the real answer and users should get into the habit of deleting old mail that they do not need to keep. Filing email from ‘critical path folders’ (Calendar, Contacts, Inbox and Sent Items) into user defined folders is also a big help.

Windows 7 – Peek, Snap and Shake

Windows 7 Logo

As ever with new operating systems, a slew of extra functionality is added. Unfortunately some neat little features are sometimes lost amongst the big functionality changes when it is publicized. I’ve been using Windows 7 for quite a few months now and one feature set that is making my life easier is all to do with the Aero Desktop. More specifically the Peek, Snap and Shake functions.

Here are some videos that demonstrate the functionality:

Peek
Snap
Shake

At first they do seem rather gimmicky ideas, but after using them for a while, I’m finding that the Snap and Shake functions are incredibly useful when you have many different Windows open and need to get through the clutter.

There are also keyboard commands that reproduce the functionality (Win = The Windows key):

  • Win and Up – Maximize
  • Win and Down – Restore/Minimize
  • Win and Left – Snap to Left of screen
  • Win and Right – Snap to Right of screen
  • Win and Home – Restore or minimize all windows other than the one in focus
  • Win and T – Cycle throw Taskbar entries.
  • Win and Space (hold) – Peek at the desktop
  • Win and G – Bring gadgets to the top
  • Win and number keys (1-9) – Open program pinned on the taskbar in order
  • Win and Plus key – Zoom in
  • Win and Minus key – Zoom out

Finding Email Addresses

Exchange Server and Outlook come with an inbuilt address book (Global Address Book – GAL) that includes a list of every mailbox on the University’s Exchange email system. There are still other email systems at work at the University and at present the users on those system do not appear in the GAL.

As this is the case, it is important that the CAMA system is used as the de facto standard for finding e-mail address or telephone numbers. You can not guarantee that the person you are trying to reach has their mailbox residing on the Exchange system.

CAMA Interface:
CAMA Interface

The Global Address List is still not without merit, but it should be used carefully. As we have so many staff and students appearing in the list, there is quite a high chance that users have the same name. The GAL should contain information detailing a user’s school / service / course to help determine a specific individual.

GAL in Outlook

Please note that the results have been blurred for the purpose of the screenshot.

1. Start typing the name of the individual that you are trying to find. The GAL will always try to navigate that list based on the user Display Name. This typically follows the Firstname, Lastname format, however due to legacy mail systems and number of users, there are users whose Display Name and email address starts only with their initials.

2. Use the scroll bar to find out more details. Most mailboxes have School / Service / Course information included to help distinguish users with the same name.

3. If you are experiencing difficult finding a user, try changing the search capacity. Changing from Name Only to More Columns allows the search field to look across multiple fields in a user’s account. This will let you search for all users with the same surname or same department for example.

4. Finally using the Advance Find function allows to specifically tailor your search for specific fields.

Removing Erroneous Entries from Outlook’s Autocomplete

Outlook offers the function to remember previously typed email address. It stores these addresses in a Nickname cache (.nk2 file). As useful as this function can be, unfortunately Outlook also remembers addresses that you enter incorrectly.

When next typing the address, the erroneous address is offered as a choice. Without checking, it is easy to select that address and repeat the problem. Fortunately it is a simple procedure to remove the problem addresses.

When creating a new message, start typing the first few letters of the previously entered address.

Autocomplete Screenshot

Please note that the addresses have been blurred for the purpose of the screenshot.

The previously entered addresses appear. You can then use the cursor keys to navigate that list. Once the incorrect address is highlighted, press the Delete key on the keyboard. That address will be removed from the list.

NB. The NK2 file that controls what appears in the autocomplete list is associated with an Outlook profile. Should you change Outlook profiles, then a different/new NK2 file will be used.

Update – Exchange Activesync Stats

Activesync Logo

As it has been roughly a year since we last published some Activesync stats on our blog, we thought it was about time to give an update.

There are 1003 users using the mobile service, which is made up of 551 Staff and 452 Students.

The statistics detail the number of different devices that sync with the Exchange servers for email / calendaring / etc.

Activesync Stats Pie Chart

A full list of device types:

Android 1
HTC Hero 17
HTC Sapphire 1
HTC Tattoo 2
Apple iPhone 493
Apple iPod Touch 96
kila 1
LGMCGD900 1
LGMCKM900 2
MOTOBLUR 2
Nokia5530 1
Nokia5800XpressMusic 6
Nokia6220c1 1
NokiaE51 2
NokiaE61 4
NokiaE63 2
NokiaE65 2
NokiaE71 34
NokiaE751 6
NokiaN78 1
NokiaN818GB 1
NokiaN82 1
NokiaN868MP 2
NokiaN95 2
NokiaN958GB 8
NokiaN96 1
NokiaN97 8
NokiaS60 1
Palm 1
PalmOneTreoAce 1
Windows PocketPC 218
Pulse 1
RoadSyncClient 1
RoadSyncClientV3 4
Windows SmartPhone 78

Failure is inevitable (or is it?)

A very thought provoking paper on why complex systems fail
How Complex Systems Fail by Richard Cook

This was referenced by John Allspaw on his blog (http://www.kitchensoap.com/2009/11/12/how-complex-systems-fail-a-webops-perspective/)

One of the most interesting points for me is number ten “All practitioner actions are gambles”. Whenever we do (or don’t do) something – upgrade a package, reboot a server, restart a service there’s a risk that it’s not going to end happily. We can (often) minimise the risk by trying the operation in a test environment first and mitigate the consequences of failure by having a backout plan (and backups :->) but sometimes our experience tells us that we should “just do it” and it will be fine. Most of the time it is but sometimes it isn’t. This leads into point seven “post accident attribution to a ‘root cause’ is fundamentally wrong”. Yes there will be a trigger whether it’s a dodgy disk controller or the (apparently) unrelated package updated last month but the _real_ problem is that the odds are against us.

When running production services we have to balance the costs of testing, scheduled downtime, redundancy against the probability of failure (and the cost of resulting unscheduled downtime). Because of these costs we may (and do) run systems with known issues. We obviously can’t do this if the problem has a direct impact on service but if it’s a failure which is masked by redundancy (say a single fibre path) and the costs and risks involved in investigating the failure and bringing the system back to perfection are judged to be too high then we might decide to leave well alone. This doesn’t make me happy but I’ve got a clearer framework to think about it now.

This ties in with “Better”, a book by Atul Gawande (http://www.gawande.com/) that I’ve just read. He’s talking about how surgeons in particular (he’s a surgeon and doctors in general make decisions and how they try to improve. A big part of this is the need for measurement and reflection – (a) collect data and (b) think about it.

Magpie wireless problems on Windows 7

Thought this might be useful for people trying to connect their Windows 7 laptop/netbook to the Magpie wireless system on campus

Problem: a Windows 7 machine (in our case, Samsung NC10) connects to magpie. The user sets up the VPN as normal; upon clicking “connect” will get the small dialog saying it’s connecting, but nothing else will happen. After some time, it will say something like “connecting via WAN Miniport”, but nothing else will happen.

Solution: For some reason, in certain circumstances Windows 7 doesn’t auto-detect the VPN type. The solution is to go into properties of the VPN connection, then the “Security” tab, then select “Point to Point Tunneling Protocol (PPTP)” from the drop-down titled “Type of VPN”. No other changes need to be made – when confirming the dialogs, the VPN should now connect.