Getting AD User Data via PowerShell

It’s a common question asked of IT – “Can you give me a list of who’s in Marketing?” or “How many accounts do we actually have?”

Before PowerShell, this was a lot harder to do. There were companies like Quest Software who provided several handy tools (and still do) , or long complicated visual basic scripts.

So, how do you get a list of users? All of this is being done from the Active Directory Module for Windows PowerShell which will install as part of the Windows Server 2012 Feature – Role Administration Tools > AD DS and AD LDS Tools > Active Directory Module for Windows PowerShell.

The ‘Get-ADUser’ command is what we’ll use to demonstrate what you can do.

For starters, ‘Get-ADUser -filter*’ will get you a list of all users, and they’ll output in this format one after the other:

powershell1 (1)

A lot of information. You can specify a single user with:

Get-ADUser -identity username

which will just show you the one result.

As you may be aware, there are a lot more fields a user has than just the ones shown. You can tell PowerShell to show you all the properties by modifying the command like this:

Get-ADUser -identity username -properties *

Note that in PowerShell v4 if you get the error “get-aduser : One or more properties are invalid.” then there may be an issue with your schema. Check out this post for more information.

If there’s just one extra property you need, there’s no point getting everything, so if you needed to see a field such as “Department” for all users then adjust the command like this:

Get-ADUser -filter * -properties Department

Now, this gives the results for every single user in your Active Directory environment. You can narrow this down to a particular OU (and consequent sub OUs) by changing the command to this:

Get-ADUser -searchbase “ou=specialusers,ou=users,dc=mydomain,dc=com” -filter * -Properties Department

Now, you might be wondering how to get rid of all the standard properties and only see the ones you want.

There are two ways to pipe out the data that you want. One is with the ‘Format Table’ and the other is ‘Select Object’. Say you want a list of staff and their departments, we only need to use the ‘name’ field and the ‘department’ field.

Here’s what the two command look like, which are very similar:

Get-ADUser -searchbase “ou=specialusers,ou=users,dc=mydomain,dc=com” -filter * -Properties Department | ft name, department

Get-ADUser -searchbase “ou=specialusers,ou=users,dc=mydomain,dc=com” -filter * -Properties Department | Select-Object name, department

powershell2

The results of these commands will look exactly the same. But, when you want to export this information out, you would normally use the ‘Export-CSV’ command. If you use the ‘ft’ option, the results will not be what you expect. There is a brief writeup on this on the Windows PowerShell Blog which shows what you’ll see and explains why. The ‘Select Object’ command doesn’t have this issue.

So, if you want to output this list to a text file, here’s the command to use:

Get-ADUser -searchbase “ou=specialusers,ou=users,dc=mydomain,dc=com” -filter * -Properties Department | Select-Object name, department | export-csv c:\temp\myfile.csv

Note that you can also cheat and just pipe any output to a textfile using the old DOS redirect output method, which works even with the ‘ft’ option:

Get-ADUser -searchbase “ou=specialusers,ou=users,dc=mydomain,dc=com” -filter * -Properties Department | Select-Object name, department > c:\temp\myfile.csv

Note that one ‘>’ creates a new file or overwrites an existing, while a double ‘>>’ will create a new file or append to an existing.

Easy! Now you can provide Active Directory details to whomever asks, with a one line command that will output only the fields you want.

TechEd North America 2014

 

5a1b31f5-50ca-403b-a339-925263e84eb2 (1)

I am really lucky this year to be going to Microsoft TechEd North America 2014, being hosted in Houston, Texas from 12th May to 15th May! Not only am I just attending, but I’ll be going as Press, representing The Register and We Break Tech.

I’ve been to TechEd Australia a few times and it’s a great experience, but this is a whole new level for me.

There will be over 10,000 people attending the single conference, a somewhat larger scale than the ~2500 that attend TechEd Australia.

To get there, I’ll have to fly Adelaide > Sydney > Dallas > Houston which will take about 24 hours, and to get back it’s Houston > Los Angeles > Melbourne > Adelaide. I’ll definitely be taking a few different gadgets and games to keep me entertained for that journey.

I don’t know what to expect exactly out of this experience. I’ll be doing writing of course, but there might be interviews, meeting and talking to world renowned experts/MVPs, mingling with Bill Gates and Satya Nadella… ok maybe not, but again I don’t really know what I’m in for!

My most similar experience was having HP fly me to Sydney for a day to cover the release of HP Converged Cloud on OpenStack technology which I live blogged and that was being thrown in the deep end – about 8 bloggers and 10 or so HP representatives there just to tell the 8 of us all a bunch of information.

Anyway, I realise this is a completely different scale and experience, and I’ll be one of hundreds of Press – but I do know this will be an awesome experience.

I’ll post some bits and pieces on here too, and I’m sure I’ll be constantly on twitter talking about my experience along with half the attendees.

Hoping to meet a bunch of new people and probably be way out of my comfort zone for the entire trip, but that’s what living is about! :)

Diverting Unassigned Numbers in Lync 2010

Lync 2010 with Enterprise Voice attaches a phone number to a user with a direct one to one relationship. This means that when a user departs, the account should get disabled along with any Lync attachments. In turn, this abandons the phone number that was attached to the user. All great by design, but what about external people that are still calling the number of the departed user?

You could leave the user’s Active Directory account disabled, leave Lync attached and configure it that way, but that’s a big hassle. Microsoft covers this scenario with a feature called “Unassigned Number”.

Unassigned Number lets you configure an Announcement on an entire number range. The idea is that if any extension in the number range configured (which can be a single number) is called and isn’t attached to a user, it will divert the call to either an Announcement or an Exchange UM Auto Attendant number. Generally just the Announcement is fine, because the Announcement can be configured to be nothing, but divert the call to wherever you want it to go afterwards.

The Announcement needs to be configured before you create an Unassigned Number Range, which can only be managed by PowerShell. The Unassigned Number Range can be created via the Lync Control Panel GUI or PowerShell which seems a bit inconsistent.

Creating an Announcement is rather easy still, with a great guide from TechNet here. The important bits are to give your Announcement a name, tell it which Lync Pool to use and give it a target SIP address to send the call to. An example command do this is:

New-CsAnnouncement -Identity ApplicationServer:lyncpool.mydomain.com -Name “Forward Announcement” -TargetUri sip:[email protected]

Note that if you use a direct phone number for the sip address, you need to append “;user=phone” or it won’t work, so the sip address should look like this: “sip:[email protected];user=phone”

Once that has been created (run a ‘get-csannouncement’ to see all the Announcements you have) you can then use PowerShell or the Lync Control Panel to create your Unassigned Number Range if you feel more comfortable there. A guide on how to do this is available from Microsoft Technet here.

All you need to do for the Unassigned Number range is give it a name, tell it the number range to start from and end (which if you have multiple sites, you’ll need multiple ranges), the name of the Announcement you want to use (i.e. where you want the call to divert to) and finally which Lync Pool server/Application Server the Announcement lives on.

Based on the Announcement above, this is what the Unassigned Number command would look like:

New-CsUnassignedNumber -Identity “Unassigned Number Range 1” -NumberRangeStart “+61712345000” -NumberRangeEnd “+161712345099” -AnnouncementName “Forward Announcement” -AnnouncementService ApplicationServer:lyncpool.mydomain.com

The number range start and end just need to be in standard international telephone format: +xx being the country code (+61 for Australia, +1 for US) and then the local number (In Australia we drop the 0 at the front).

Again, you can run a ‘get-csunassignednumber’ command to see how it’s been configured.

Once you’ve done the above, you’re set. Try calling any unassigned number that you have and it should divert to the sip address you configured on the Announcement. If they’re a Lync user (as you can enter a phone number and divert these calls out) they will also get a message with the incoming call saying it was diverted from the originally dialled number.

If you have a special requirement where a particular number range needs to go elsewhere, you can just create more Announcements and unassigned number ranges – the order of the unassigned number ranges will define which range rule is applied with a highest first approach.

I believe this is very similar in Lync 2013, and would recommend that anyone using Lync with Enterprise Voice set this up for easier management of their phone system, but also to make sure no important business calls are missed.

Nokia Lumia 1520 Review

Nokia’s shot at the growing phablet market.

On the 11th December 2013, Nokia released its latest Windows Phone in the Lumia range – the 1520.

Following up from the Lumia 1020 with its flagship 41 megapixel camera, Nokia went for a different extreme on the 1520 with a 6 inch display.

Other impressive specifications include a full HD 1920 x 1080 resolution on the giant display, a 20 megapixel camera (which is still better than most other smartphones on the market), a quad-core processor, and finally a 3400mAh battery. That beefy battery is supposed to provide 32 days standby time, and my heavier real-world use averaged 2 to 3 days between charges.

Software-wise, this is the first phone to run Nokia’s “Black” update which will end up being available to all Lumias, so that’s no reason to consider this particular phone. The hardware is what makes it or breaks it, so that’s what this review will focus on.

 

wp_ss_20131227_0001Lumia Black

Good

Weight wise, it’s not a light phone at 209g. It is much heavier than an iPhone 5S at 115g or a Samsung Galaxy Note 3 at 168g, but I don’t consider it too heavy.

The screen is the number one reason I’d recommend this phone. The amount of real estate you get will make you reconsider using a laptop to do lighter tasks, and the large number of tiles you can fit on a single screen means you can glance at your phone and see everything you need to know.

 

wp_ss_20131224_0001The home screen fits a crazy amount of fully customisable tiles.

The long battery life means that you’re much less worried about charging your phone at every chance you get, which is a refreshing change from most other smartphones.

Bb9ViqtCQAAa1xc
“Battery” app – free from Enless Soft

 

Bad

There is only one official case for the 1520, and that’s the CP-623. It’s the standard ‘clip on the corners’ cover that most other Lumias have available, but with an added protective flap. The flap doubles as a stand, but it’s not stable enough to actually use the phone while in stand mode. It can only be stood sideways, and many things don’t actually rotate sideways (like the all-important home screen) so it has very limited functionality.

Other accessories like official charging stands and car chargers don’t fit this gargantuan particularly well either. They do work, but it’s a bit of a balancing act to put the 1520 on a charging stand, and a very tight squeeze to fit in the car charger when the official case is attached too.

Other

I’m still not sure if the size of this device is a good or a bad thing, and that should come down to individual taste. When I first held it, I thought it’d be too big. Initially it felt a bit weird both sitting in my pocket as well as just holding it, but after a week or so I’m now used to it. I came from a Nokia Lumia 1020 which is still a decent 4.5″ screen, but this phone does take some getting used to.  You’re going to need a large pocket to carry it around.

Summary

The Nokia Lumia 1520 is a solid phone. It’s faster than any other Lumia before it, with the best battery life and screen so far in the Lumia range. Once you get used to its size, it may end up being your default ‘go-to’ device for most basic tasks, as it’s already in your pocket (or half sticking out of it). I’m already worried how I’d go back to a smaller phone, and that’s a good sign.

Nvidia GTX 560ti to AMD R9 280X Upgrade

It was time to update my graphics card. I decided this because I’d been playing a lot of Battlefield 4 and there was some occasional screen ripping. So, did I see much of an improvement with this jump?

My system specs are:

Motherboard: AsRock Z68 Extreme3 Gen3
CPU: Intel i5-2500K CPU @3.3Ghz
HDD: Corsair Force 3 SSD 120gb
RAM: 2 x 4gb 1333mhz DDR3 G.Skill
Graphics: 1GB NVidia GeForce GTX 560 Ti with GeForce driver 334.57 Beta

First I thought I’d run the inbuilt Windows Experience Index to see how that went. In Windows 8.1 I was surprised to not actually find this option, and found out after reading this article that Microsoft had now made it command line only.

WP_20140215_08_52_42_ProNVIDIA GTX 560ti

My results were:

CPUScore : 7.8
D3DScore : 8.2
DiskScore : 7.3
GraphicsScore : 8.2
MemoryScore : 7.8

Next up was a 3DMark Demo, which had the following results:

http://www.3dmark.com/3dm/2456981
(note – no idea why RAM is running at 800mhz, so will investigate later)

FIRE STRIKE 1.1 3132

CLOUD GATE 1.1 14936

ICE STORM 1.2 156208
Enough tests, time to replace a graphics card!

I purchased a 3GB Sapphire AMD R9 280X. I could have gone the NVIDIA GTX 760 for a little less, but that was the 2GB variant. There was a 4GB variant, but that was slightly more expensive than the AMD card, so I decided the 3GB was a good middle ground and should last a bit longer with the extra memory.

The install went rather smoothly, until I installed the AMD drivers via Windows Update. They successfully installed, but then doing simple things like right clicking on the desktop took ages to bring up a menu. I decided to uninstall anything NVIDIA I could find, but some of the programs just wouldn’t uninstall.

I decided to use Display Driver Uninstaller which promises to clean up everything relating to the display driver you choose. Word of warning – when it has three options and one is ‘unrecommended’ but you’re being lazy trying to avoid reboots, don’t choose that option. I ended up getting screens that wouldn’t display anything properly, so had to recover to a last known working version of Windows 8.1 (which is rather easy to do!).

Attempt #2 I ran the safe mode option to uninstall NVIDIA using the above tool, and it worked perfectly. After rebooting, right clicking on the desktop was instant and everything NVIDIA related was gone from Programs and Features in Windows.

  WP_20140215_08_52_48_ProAMD R9 280X

So, first up is an updated Windows Experience:

CPUScore : 7.8
D3DScore : 8.2
DiskScore : 7.3
GraphicsScore : 8.2
MemoryScore : 7.8

The exact same scores. Weird as I’d run the ‘winsat prepop’ and saw it rerun all the tests. I thought I’d try a tool that ran a GUI interface over the command with probably a few extra smarts – CHRISPC WIN EXPERIENCE INDEX which worked easily and is a neatly written and designed bit of software.

This gave different results of 8.5 for the GraphicsScore and D3DScore.

How about the 3DMark results? Here’s the updated results:

http://www.3dmark.com/3dm/2457909

FIRE STRIKE 1.1 7244

CLOUD GATE 1.1 19054

ICE STORM 1.2 173745

A huge improvement in numbers.

Back to Battlefield 4 and without changing any settings, everything felt a lot more fluid for movement. I changed the settings back to ‘auto’ and noticed even more improvements – a lot of textures were smoother and generally better looking.

WP_20140215_08_52_36_ProAbove: AMD R9 280X – Below: NVIDIA GTX 560ti

Size wise, the newer AMD card is much larger, but this is partly because it’s a higher end video card than the NVIDIA. At time of purchase the AMD was $388AU.

Overall I’m happy with my decision as it gave me the better experience I was looking for. If you’re considering a similar upgrade then keep in mind the added power requirements for a higher end video card.