Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Lets say I want to do the very simple query in AD

dsquery user -name "John Smith" | dsget user -memberof -expand

This will output the DNs of the AD groups that this user belongs to. I can make it print the friendly group name via:

dsquery user -name "John Smith" | dsget user -memberof -expand | dsget group -samid

However if a group has a hash tag in it (e.g. "CN=#Kentucky Office,OU=#Distribution Lists,DC=myenterprise,DC=local") will fail with the following error:

dsget failed:Value for 'Target object for this command' has incorrect format.

The way to fix this is to unescape the hashes (i.e. "CN=#Kentucky Office,OU=#Distribution Lists,DC=myenterprise,DC=local"). I can do this in powershell via the oneliner:

dsquery user -name "John Smith" | dsget user -memberof -expand | ForEach-Object { $_.Replace('\#', '#')  } | dsget group -samid

Is there a solution that does not involve powershell.exe or even adding an executable to the pipe besides dsquery or dsget?

share|improve this question
    
Find isn't an external executable, is it? :) Or do you not want to pipe anything? –  Trevor Sullivan May 10 '11 at 20:13
    
How would I do the replace with find.exe? Also, I'm not so much against involving other things a ds*.exe pipe chain. However, in this case, the mismatch between output and input strikes me as a bug. I'd love to report this to connect, but I don't have access to the Windows Server Connect site. –  Justin Dearing May 10 '11 at 20:19
    
Wait a second .. I have no idea what I was thinking earlier. Forget I said that. Find is a built-in command to cmd.exe, not an external executable, but I still have no idea why I even suggested that. –  Trevor Sullivan May 10 '11 at 21:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.