Windows – how to remotely connect to windows server 2012 using psexec

networkingwindowswindows-server-2012-r2

I want to connect to windows server 2012 which is an aws ec2 instance. I tried using psexec but it showing error as Make sure that the default admin$ share is enabled on WIN-G2QOH****. i tried all possible ways like 1. reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f 2. Go to C:\windows and right-click –> properties and hit 'advance sharing' . From there click the check box 'Share this folder' . Enter the name admin$ and hit Permissions. I would recommend removing 'Everyone' and adding just the users that the PsExec command will use to execute.

Run the PsExec command again and this should resolve your issue.

Edit: You can turn on your AutoShareServer, which will automatically create the admin shares.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\AutoShareServer Change the AutoShareServer key to 1
still it is not working for me..

Best Answer

To test if your folder is correctly shared and accessible from outside you czn try with a net use command :

net use \\your.ip.or.domain.name\Admin$ /user:admin-account password_of_admin

If you have a mount, this part is ok. If you don't have a share, it's not necessary to test with psexec, it will fail.

Moreover, be sure your ports are well forwarded, and yours firewalls are correctly configured for the port 135.