0

I have the following in myFile.txt:

samid xxuserMike xxuserDave xxuserSue dsget succeeded

I'd like to use a batch commands to make it: "xxuserMike" "xxuserDave" "xxuserSue"

Side note, the original file is created using dsquery / dsget to make a list of users from a specific group in AD. If there is a way to format that output from the start, all the better. The command I'm using is: dsquery group -name "myADgroup" | dsget group -members | dsget user -samid > myFile.txt

1 Answers1

0

Try this:

@echo off
setlocal enabledelayedexpansion
(for /f "skip=1" %%a in (
  'dsquery group -name "myADGroup"^| dsget group -members^| dsget user -samid'
  ) do ( 
    set l="%%a"
    echo(!l:"dsget"=!
))>myfile.txt
Matt Williamson
  • 6,947
  • 1
  • 23
  • 36
  • Thanks Matt, that's close but it's putting: ( "xxuserMike" ( "xxuserDave" etc. would you mind helping me remove the "( " as well? –  Feb 26 '14 at 22:40
  • ok, I removed the last ( in the code you provided and everything looks good, it just says "Echo is off." at the end of the file. If I can just suppress that I'll be golden. Thanks –  Feb 26 '14 at 23:47
  • `echo(!l:"dsget"=!` <--- try it as posted. You must have put a space after the `echo` – foxidrive Feb 27 '14 at 05:02
  • Thanks foxidrive, that was it. –  Feb 27 '14 at 05:39