-1

I am currently trying to get a patch list of a remote server and export the results on to my c:\temp\ folder or on to a network path. I currently have the below code with PSEXEC.

Psexec \\servername  wmic qfe list brief > \\Pathtofolder\General\Test\patches.txt

or if I could get this to export locally on my system

Psexec \\servername  wmic qfe list brief > c:\temp\patches.txt

When I run this with the UNC patch I get the below errors:

Couldn't access servername: The handle is invalid. Connecting to servername...

But if I run the command without putting any export path it works absoloutely fine and returns the correct information to my command window.

Psexec \\servername  wmic qfe list brief 

Not sure what else I can do.

Also I can not use the powershell get-hotfixid command I need to use this or similiar.

Thanks in advance,

SG

user3290171
  • 121
  • 1
  • 3
  • 19
  • `wmic /node:servername /output:C:\temp\patches.txt qfe get` –  Sep 19 '16 at 00:29
  • I get the error message invalid global switch? – user3290171 Sep 19 '16 at 00:43
  • Just manage to get it to work.. just needed to put "" around the server name. Thanks for the help! :) – user3290171 Sep 19 '16 at 00:51
  • If you do `/node:@"c:\computerlist.txt"` it will run the command on all servers listed in the text file. –  Sep 19 '16 at 00:56
  • Noodles, how would i make it so it would export one .txt document for each server. The .txt would be the name of the server and the .txt would contain patches installed on that server? – user3290171 Sep 19 '16 at 02:11

1 Answers1

0
for /f "usebackq delims=" %A in ("%userprofile%\desktop\computerlist.txt") Do wmic /node:%A qfe get > "%userprofile%\desktop\%A.txt"

Use %%A in a batch file and %A interactively.

This command builds a list of turned on computers.

for /f "skip=3 delims=\" %%A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %%A