We help IT Professionals succeed at work.

Find all folder sessions on a remote machine

474 Views
Last Modified: 2010-03-05
Hi,

I want to find all the shares,session details on a remote machine from my machine.Can i get all these details to a file.

REgards
Sharath
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
        Hi Sharath
                 for /f %x in (c:\computers.txt) do psexec %x net session >>result.txt

Regards
Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
I think you can also do this without using PSExec.. like:
for /f "delims=#" %x in (c:\computers.txt) do net session \\%x >>c:\result.txt

Author

Commented:
Mshusy.

I get this.


C:\Pstool>psexec in-isa-srv01 net session  1>>c:\result.txt

PsExec v1.63 - Execute processes remotely
Copyright (C) 2001-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

PsExec could not start in-isa-srv01:
Logon failure: unknown user name or bad password.

C:\Pstool>psexec in-ads-srv02 net session  1>>c:\result.txt

PsExec v1.63 - Execute processes remotely
Copyright (C) 2001-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

PsExec could not start in-ads-srv02:
Logon failure: unknown user name or bad password.

farhankazi:

I get this

C:\>net session \\inexchange1  1>>c:\result.txt
A session does not exist with that computer name.

More help is available by typing NET HELPMSG 2312.


C:\>net session \\dev-chen-pc2149  1>>c:\result.txt
A session does not exist with that computer name.

More help is available by typing NET HELPMSG 2312.


C:\>net session \\in-isa-srv01  1>>c:\result.txt
A session does not exist with that computer name.

More help is available by typing NET HELPMSG 2312.


C:\>net session \\in-ads-srv02  1>>c:\result.txt
A session does not exist with that computer name.

More help is available by typing NET HELPMSG 2312.
CERTIFIED EXPERT
Top Expert 2007

Commented:
         Hi Sharath
               Most probably you are running command from a user which is not admin on remote machines. Try following
           for /f %x in (c:\computers.txt) do psexec %x -u adminusername -p adminpassword net session >>result.txt

Regards
CERTIFIED EXPERT
Top Expert 2007

Commented:
correction

for /f %x in (c:\computers.txt) do psexec %x -u domainname\adminusername -p adminpassword net session >>result.txt

Author

Commented:
When i run this

C:\Pstool>psexec \\dev-chen-pc100 net session 1>>C:\\r.txt

I get a file with all the sessions but running your script a file is created but no data in it.
CERTIFIED EXPERT
Top Expert 2007

Commented:
         Hi Sharath
                 c:\\r.txt is incorrect. Put single \
 
Regards

Author

Commented:
Ok why is the single machine command working and your command to take machine names from the file not working.
CERTIFIED EXPERT
Top Expert 2007

Commented:
         Hi Sharath
               Where does 1 come from? It may cause it malfunction (may show session 1 only). Try removing 1

Regards        
CERTIFIED EXPERT
Top Expert 2007

Commented:
         Also make sure that you didn type like
              for /f %x in (c:\\computers.txt) do psexec %x -u domainname\adminusername -p adminpassword net session >>result.txt
               Below is the correct one
             for /f %x in (c:\computers.txt) do psexec %x -u domainname\adminusername -p adminpassword net session >>result.txt


Regards
CERTIFIED EXPERT
Top Expert 2007

Commented:
         Hi Sharath
                 Any update?

Regards

Author

Commented:
I get this.

C:\Pstool>for /f %x in (c:\computers.txt) do psexec %x -u development\administra
tor -abc123 net session >>result.txt

C:\Pstool>psexec dev-chen-mrd100 -u development\administrator -abc123 net sess
ion  1>>result.txt

PsExec v1.63 - Execute processes remotely
Copyright (C) 2001-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

PsExec could not start dev-chen-mrd100:
Logon failure: unknown user name or bad password.

C:\Pstool>psexec dev-chen-pc100 -u development\administrator -abc123 net sessi
on  1>>result.txt

PsExec v1.63 - Execute processes remotely
Copyright (C) 2001-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

PsExec could not start dev-chen-pc100:
Logon failure: unknown user name or bad password.

I am running this from a domain admin lofin also
CERTIFIED EXPERT
Top Expert 2007
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.