none
Deleted RRS feed

All replies

  • $sb = {
        $remote_session = New-PSSession -ComputerName server_1
        Get-ChildItem -Path c:\folder_src -Recurse |
        Copy-Item -Destination c:\folder_dst -ToSession $remote_session
    }
    Start-Job -ScriptBlock $sb -Credential username


    \_(ツ)_/

    Tuesday, January 8, 2019 1:49 PM
  • Deleted
    Tuesday, January 8, 2019 5:18 PM
  • If in a domain then use domain credentials which will be used for the remote connection by default.  There is no need to use remote credentials with New-PsSession when running under a domain account that has remoting permission.

    If in a workgroup then pass the credential object to the job  as an argument.

    Start-Job -ArgumentList $credentials …

    Or -

    $sb = {
        param($session)
        Copy-Item -Path c:\folder_src -Destination c:\folder_dst -Recurse -ToSession $session
    }
    $session = New-PSSession -Name MySession -ComputerName server_1
    Start-Job -ScriptBlock $sb -ArgumentList $session


    \_(ツ)_/

    Tuesday, January 8, 2019 5:53 PM
  • I have tried this before but I always get permissions issue.

    The safest way that I was able to do it is to use the C:\Temp folder on the server.

    Example:

    clear
    $servername = 'DESTSERVER'
    Copy-Item "c:\source_folder\file.txt" -Destination "\\$servername\C$\Temp\file.txt"



    • Edited by RATG Friday, January 11, 2019 4:28 AM changed the c: to c$
    Friday, January 11, 2019 2:21 AM
  • I have tried this before but I always get permissions issue.

    The safest way that I was able to do it is to use the C:\Temp folder on the server.

    Example:

    clear
    $servername = 'DESTSERVER'
    Copy-Item "c:\source_folder\file.txt" -Destination "\\$servername\C:\Temp\file.txt"


    Look at your code.  It will not work.  Remote systems do not have drive letters.


    \_(ツ)_/

    Friday, January 11, 2019 2:23 AM
  • I fixed it. C: should be C$.

    clear
    $servername = 'DESTSERVER'
    Copy-Item "c:\source_folder\file.txt" -Destination "\\$servername\C$\Temp\file.txt"

    • Proposed as answer by RATG Saturday, January 19, 2019 1:44 AM
    Friday, January 11, 2019 4:30 AM
  • I fixed it. C: should be C$.

    clear
    $servername = 'DESTSERVER'
    Copy-Item "c:\source_folder\file.txt" -Destination "\\$servername\C$\Temp\file.txt"

    Please stop adding nonsense to other users questions.  It is annoying and serves no helpful pupose the the user  who is asking a question.


    \_(ツ)_/

    Saturday, January 19, 2019 1:53 AM