1

I'm trying to issue the following command remotely:

netstat -ano > C:\output.txt

but cannot figure out how to do that with WMIC! Any idea?

I've got:

process call create netstat.exe 

working but I cannot figure out how to pass the -ANO nor the output. Help please :)

coddrego
  • 11
  • 1
  • 1
  • 2

3 Answers3

2

When issuing remote commands, quote the entire string to execute, like:

wmic /node:remote_computer process call create "netstat.exe -ano > C:\output.txt"
RobW
  • 2,766
  • 1
  • 17
  • 22
  • You probably need to add a `/output:stdout` because it does not do this by default if *you want the file on the remote computer* (that is ambiguous in your question), or it will be a useless output file. It took me a long time with wmic to figure that out. – songei2f Sep 23 '11 at 08:00
  • To add to the question, id like the output to be redirected to the remote machine (the issuer). Thanks! – coddrego Sep 23 '11 at 15:29
-1
wmic /node:remote_computer process call create "cmd /c \"pushd \\remote_server\c$ && netstat -nao > n.txt && popd\""
peterh
  • 4,914
  • 13
  • 29
  • 44
Anon
  • 1
-1

Another option to get the list of open connections on a computer is to use PowerShell and/or WMI: https://www.action1.com/kb/list_of_open_tcp_ip_connections_on_remote_computer.html

With PowerShell, for example, you can filter or sort the results or even query multiple computers at the same time:

Get-ADComputer -Filter {OperatingSystem -Like “Windows 10*”} | ForEach-Object {Get-WmiObject -Class MSFT_NetTCPConnection -Computer $_.Name}

chicks
  • 3,639
  • 10
  • 26
  • 36
  • 1
    Please a least give one example in your answer as text instead of just an URL. – Patrick Mevzek Dec 20 '17 at 22:54
  • 1
    Welcome to Server Fault! Your answer suggests a workable solution to the question is available via another website. The Stack Exchange family of Q&A websites [generally frowns on this type of answer](https://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers). Please read [How do I write a good answer?](http://serverfault.com/help/how-to-answer) and consider revising your answer to include the steps required to resolve the issue. And don't forget to take the [site tour](http://serverfault.com/tour). – Paul Dec 21 '17 at 01:42