Modifica un file di testo utilizzando un file batch
-
21-12-2019 - |
Domanda
Ho il seguente in myfile.txt:
samid
xxuserMike
xxuserDave
xxuserSue
dsget succeeded
Mi piacerebbe usare un comandante batch per farlo:
"xxuserMike"
"xxuserDave"
"xxuserSue"
Nota laterale, il file originale viene creato utilizzando Dsquery / DSGet per effettuare un elenco di utenti da un gruppo specifico nell'annuncio.Se c'è un modo per formattare quell'output dall'inizio, tutto meglio.Il comando che sto usando è:
dsquery group -name "myADgroup" | dsget group -members | dsget user -samid > myFile.txt
Soluzione
Prova questo:
@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
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow