Srinivas Reddy
asked on
Run commands remotely
How do i run remotely commands on a machine .to let suppose find a file in D Drive if it exists or not from my local machine .
Here are the details
My local machine is in A domain and i connect to jump server through B Domain credentials .from there i connect to Windows Server 2003 through service account credentials.
I need to run a command find /N /I "String" D;/Man/SC.txt (for example) from my local machine on that remote windows server .How do i achieve that .Everytime I need to RDP to jump server an then onto windows server .How can i acheive this using psexec or some tool .
Here are the details
My local machine is in A domain and i connect to jump server through B Domain credentials .from there i connect to Windows Server 2003 through service account credentials.
I need to run a command find /N /I "String" D;/Man/SC.txt (for example) from my local machine on that remote windows server .How do i achieve that .Everytime I need to RDP to jump server an then onto windows server .How can i acheive this using psexec or some tool .
\\server\D$\
ASKER
can you elaborate further on how to use psexec .
ASKER
The file is on D Drive .I dont know if its local file system or a NAS (Share) or SAN (LUN).
You need to know what type it is
Local via iscsi, FC, sas connected.... \\servername\d$ should work.
If admin share is accessible.
You are providing non specific info.
Remote to theserver and search while local to theserver.
Local via iscsi, FC, sas connected.... \\servername\d$ should work.
If admin share is accessible.
You are providing non specific info.
Remote to theserver and search while local to theserver.
ASKER
I find it useful but not the one I'm looking for . I can login to the jump serever and then to the server and run locally commands.
To access non shared folders your only path as an administrative share.
The other option deals with using psexec to run the find command on the server gettinv output.
The other option deals with using psexec to run the find command on the server gettinv output.
ASKER
Thanks for your help .But Need psexec working in order to avoid logging into server again and again .
Download psexec from Microsoft's sysinternals
Psexec /s /m \servername /c 'find "string" "d:\"
You need to make sure the wi does firewall on the remote server will allow the incoming.
Psexec /s /m \servername /c 'find "string" "d:\"
You need to make sure the wi does firewall on the remote server will allow the incoming.
ASKER
I have downloaded the sysinternals on my local machine and i am running from local machine .psexec \\ServerName -u gadd -p Marc20! /c find "MRC021R" "D:\Srinivas" . (D:\Srinivas is on Jump Server) . First I got this error I'm getting Make sure that the default admin$ share is enabled on ServerName .Now I.m getting access denied error .
psexec \\148.92.136.196 -u prod(Domain Name )\gadd -p March2020! -s find /I /N "MRC021R" D:\Srinivas
Access denied - D:\SRINIVAS
find exited on 148.92.136.196 with error code 1.
I did a tracert on that machine .
Here is the output .
1 1 ms 5 ms <1 ms 204.230.105.1
2 1 ms 1 ms 1 ms 172.18.1.3
3 * * * Request timed out.
4 44 ms 44 ms 44 ms 10.25.1.1
5 49 ms 49 ms 49 ms 10.25.1.2
6 49 ms 49 ms 49 ms 15.175.152.114
7 * * * Request timed out.
8 61 ms 59 ms 58 ms [144.92.136.195]
Trace complete.
psexec \\148.92.136.196 -u prod(Domain Name )\gadd -p March2020! -s find /I /N "MRC021R" D:\Srinivas
Access denied - D:\SRINIVAS
find exited on 148.92.136.196 with error code 1.
I did a tracert on that machine .
Here is the output .
1 1 ms 5 ms <1 ms 204.230.105.1
2 1 ms 1 ms 1 ms 172.18.1.3
3 * * * Request timed out.
4 44 ms 44 ms 44 ms 10.25.1.1
5 49 ms 49 ms 49 ms 10.25.1.2
6 49 ms 49 ms 49 ms 15.175.152.114
7 * * * Request timed out.
8 61 ms 59 ms 58 ms [144.92.136.195]
Trace complete.
The user you are using, level, administrative?
Instead of /c try cmd.exe
You are connecting across the Internet?
are you running psesc
Psexec \\servernamr /s cmd.exe
What happens?
Instead of /c try cmd.exe
You are connecting across the Internet?
are you running psesc
Psexec \\servernamr /s cmd.exe
What happens?
ASKER
The user i m using is my user id credentials on that jump server .Im running the command from my local machine .I'm using psexec not psesc .Normally I will be able to RDP to login with the crednetials which i m using in the commnd .
ASKER
Do I need to chnage the permissions on the SRinivas folder in D Drive on Jump Server .How do i Hide the password ,and How do i run with administrator prviliges .
if you are logged as that user, you do not need to provide a password.
-s /s means to run the remote with system privilege which means your user you use has to be administrative to run as system.
Try running without specifying -s /s and just see f you can get the cmd.exe on the other side.
Exit to end the psexec remote session.
-s /s means to run the remote with system privilege which means your user you use has to be administrative to run as system.
Try running without specifying -s /s and just see f you can get the cmd.exe on the other side.
Exit to end the psexec remote session.
ASKER
Didnt help for me .
You have the access and the eyes on the issue. what happens when you try
psexec \\servername cmd.exe?
please don't just say it did not work.
Look at the options
https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
psexec \\servername 'dir /s d: | find "pattern" `
psexec \\servername cmd.exe?
please don't just say it did not work.
Look at the options
https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
psexec \\servername 'dir /s d: | find "pattern" `
ASKER
C:\Sysinternals>psexec \\18.2.136.16 -u production\gaddam find /N /I "MRC019R" D:\Srinivas
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Password:
Access denied - D:\SRINIVAS
find exited on 18.2.136.16 with error code 1.
Searching for a file called MRC019R.I tried
psexec \\servername 'dir /s d: | find "pattern" ` as well .Are we facing any port issues or network issues or any services .Becuse manually i can login to the server and open the file .
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Password:
Access denied - D:\SRINIVAS
find exited on 18.2.136.16 with error code 1.
Searching for a file called MRC019R.I tried
psexec \\servername 'dir /s d: | find "pattern" ` as well .Are we facing any port issues or network issues or any services .Becuse manually i can login to the server and open the file .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks It did work .
Look at psexec as the means by which you can connected.
Your question suggests the file is not part of a share.