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:



About Mike F Robbins

Mike F Robbins is a Microsoft MVP on Windows PowerShell and a SAPIEN Technologies MVP. He is a co-author of Windows PowerShell TFM 4th Edition and is a contributing author of a chapter in the PowerShell Deep Dives book. Mike has written guest blog articles for the Hey, Scripting Guy! Blog, PowerShell Magazine, and He is the winner of the advanced category in the 2013 PowerShell Scripting Games. Mike is also the leader and co-founder of the Mississippi PowerShell User Group. He blogs at and can be found on twitter @mikefrobbins.
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