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:


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:


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:


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:


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:




  1. Johnny Reel

    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. Bjorn Houben

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

  3. Bjorn Houben

    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

    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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: