0

i need assistance on a error showed to me when i try to did it on command line:

wmic /node:brspd030 computersystem get caption >>\\brspd010\c$\users\machael1\desktop\gpresult.txt & psexec \\brspd030 gpresult -r | findstr /i "WSUS" >>\\brspd010\c$\users\machael1\desktop\gpresult.txt

Output:

Caption
BRSPD010
††††浏慹圠啓⁓流畂楳敮獳䍐൳ †††传祭⁡南单䄠䉭獵湩獥偳獃਍††††䵅䅅圠啓⁓敒潰瑲牥൳

Ideal output: caption and result from the Wsus research in the gpresult, i will use this command in the loop with some computers "for %i in (.txt).

Could you help me please?

Sam Denty
  • 3,693
  • 3
  • 30
  • 43
  • Your question states that an error was shown to you, but you appear not to have provided us with any error. _It looks to me like your commands have both worked_. – Compo Apr 03 '17 at 16:35

1 Answers1

3

The output of the wmic command is BOM prefixed two bytes per character utf-16le encoded, but the output of the gpresult is 1 byte per character ansi encoded. When read, each two bytes of the gpresult output are handled as one character and seen as indicated.

Maybe the easiest way to solve it is to filter the output of the wmic command

wmic computersystem get caption | more >> outputFile.txt

edited to adapt to comments

>>\\brspd010\c$\users\machael1\desktop\gpresult.txt ((wmic /node:brspd030 computersystem get caption | more) & (psexec \\brspd030 gpresult -r | findstr /i "WSUS"))
MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Nevermind, being also a non native English speaker I'm glad I can sometimes help, knowing of my own mistakes especially in comments which are only correctible for 5 minutes. –  Apr 03 '17 at 16:42
  • hello, thanks for your reply. could you give to me a way to solve my problem? – Elivelton Andrade Apr 04 '17 at 12:17
  • i need to sent a command line to receive in a txt file the name of the computer with the WSUS (gpresult) result as i showed in the command line. – Elivelton Andrade Apr 04 '17 at 12:18
  • @EliveltonAndrade, answer updated. – MC ND Apr 04 '17 at 13:23
  • Thanks for your reply, i tested and it is working, but only a question, when i try to do with "for", doesn't paste in txt the "gpresult". below the code that i tried use. for /f %1 in (user_plant.txt) do >>\\brspd010\c$\users\machael1\desktop\gpresult.txt ((wmic /node:%1 computersystem get caption | more) & (psexec \\%1 gpresult -r | findstr /i "WSUS")) could you help again? – Elivelton Andrade Apr 05 '17 at 12:01
  • i found my error, sorry. Thanks for your reply, do you know any way to i learn windows command better ? i'd like to learn. – Elivelton Andrade Apr 05 '17 at 12:07