Remote access to a server

Welcome Forums General PowerShell Q&A Remote access to a server

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
1 month, 4 weeks ago.

  • Author
    Posts
  • #114181

    Participant
    Points: 0
    Rank: Member

    Hello,

     

    In my company i have to write a script that can :

    1) "Connect to an other server" (\\Serveur\x$\the\path) as a specific user (with password)

    2) "Get a html file"

    3) "Put it on the first server (x:\the\path\i\chose)

     

    for some reasons i can ping the remote server, i can manually access to (\\Serveur\x$\the\path) but i can't do it with Powershell.

    May i have some help ?

    Best regards,

  • #114187
    Jon

    Participant
    Points: 36
    Rank: Member

    2012 and newer already have remoting enabled, you will need to enable it for anything older than 2012. If it's 2012+ and not working take a look at the links below

    https://docs.microsoft.com/en-us/windows/desktop/winrm/installation-and-configuration-for-windows-remote-management

    https://leanpub.com/secretsofpowershellremoting

     

     

  • #114201
    vjs

    Participant
    Points: 2
    Rank: Member

    Hi,

    Please make a below check on the both the servers in picture.

    0. Server should ping each other and try to access SMB share for both using
    \\Server01\C$\

    1. Check firewall settings using the below command and match
    netsh advf show allp state

    2. Check WinRM service on both machines also check if Port 5985 is responding to Telnet

    3. Check Execution Policy by command Get-ExecutionPolicy.
    Kindly set the execution policy to Unrestricted or Bypass the execution policy in order to establish connection.

    4. Try enter-pssession Server01 or invoke-command to remotely access the server.

    Incase you still face an issue do share the Error so that we can proceed further.

    Thanks
    Vikramjit

  • #114202

    Participant
    Points: 0
    Rank: Member

    First of all thanks for your answers.

    I found some interesting things with "net use" and i tried this way :

    net use L: $from_path /user:$username $pass

    copy-item $from_path'\replication.html' -Destination $to_path

    net use L: /delete

    But the fact is that it works when i put command one by one in PowerShell but i am having a "system error 129 : Multiple connections to a server or resource shared by the same user, using more than one user name, are not allowed. Delete all previous connections to the server or shared resource and repeat."

    It is strange that it is working one way but not the other..

You must be logged in to reply to this topic.