Helping Others at Microsoft TechEd with PowerShell 911

While at Microsoft TechEd last week, I met a gentleman from Europe who was experiencing a particular issue with the Get-ADUser PowerShell cmdlet.

When Get-ADUser is used with a hard coded value such as name as shown in the following example, it returns the expected information without issue:

052214-1

The issue is that when the name, for example, is stored in a variable and double quotes are used to try to expand the variable, nothing is returned:

052214-2

For the life of us, we couldn’t lay our hands on a test system with the Active Directory cmdlets on it at TechEd and neither of us had a computer with us that particular day. Luckily I had a test PowerShell Web Access system exposed to the Internet that I was able to log into from my phone over 3G, replicate the problem, and come up with a solution:

052214-3

I brought this up at the PowerShell dinner at TechEd and ended up speaking to the person who is in charge of the team that came up with PowerShell Web Access. He actually had me bring it up on my phone at the dinner and took a picture of me holding my phone up while logged into PSWA to take back to his team. A bit of trivia that he told me about was that PowerShell Web Access was originally called “PowerShell 911″.

The solution I gave was to use double quotes instead of curly braces and single quotes around the variable since the quote marks on the outside always win:

052214-4

I saw the same gentleman at the closing party and mentioned that dropping the quotes altogether would probably allow it to work inside the curly braces, and indeed it does:

052214-5

µ

About Mike Robbins

PowerShell Enthusiast | IT Pro | Winner of the Advanced Category in the 2013 PowerShell Scripting Games | Author of Chapter 6 in the PowerShell Deep Dives Book.
This entry was posted in Active Directory, PowerShell and tagged , . Bookmark the permalink.

4 Responses to Helping Others at Microsoft TechEd with PowerShell 911

  1. Excellent tip. You never know when you might be faced with a similar problem while on the road. I too have plans for a Powershell portal, (Almost ready as I type.).

  2. I didn’t expect it was possible to use double quotes instead of curly braces, but thanks for the info.

  3. Before I forget … for quick testing without having your own lab you can also use the Technet Virtual Labs. It does require a computer though.

  4. Graeme says:

    Mike, what is your setup to be able to do this? I’d love to set it up. What type of hardware is running (so I have an idea power wise).

Leave a Reply