none
posh-ssh remote file share as localfile path RRS feed

  • General discussion

  • any idea how I can use a remote file share as a local file path?

    $Credential = get-credential

    $FilePath = 'P:\'
    $sftppath = '/home/user'
    $remoteIP = '10.50.233.13'

    $session = New-SFTPSession -ComputerName $remoteIP -Credential $Credential

    # Upload the file to the SFTP path
    Set-SFTPFile -SessionId ($Session).SessionId -LocalFile $FilePath -RemotePath $sftppath

    P was a drive I create via

    New-PSDrive -Name "P" -PSProvider "filesystem" -Root "\\server\share"

    but got error

    Set-SFTPFile : File to upload \\server\share was not found.
    At line:21 char:1
    + Set-SFTPFile -SessionId ($ThisSession).SessionId -LocalFile $FilePath ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (\\server\share\:String) [Set-SFTPFile], FileNotFoundException
        + FullyQualifiedErrorId : File to upload \\server\share\ was not found.,SSH.SetSftpFile


    • Edited by JonDoe321 Monday, April 8, 2019 10:59 PM
    • Changed type Bill_Stewart Wednesday, September 4, 2019 8:53 PM
    • Moved by Bill_Stewart Wednesday, September 4, 2019 8:53 PM Help vampire
    Monday, April 8, 2019 10:59 PM

All replies

  • what can i do to transfer a file from windows share \\server\share  to linux machine?

    I looked at posh-ssh but my computer has no internet access and cannot download this module

    • Merged by Bill_Stewart Tuesday, April 9, 2019 7:51 PM Duplicate
    Monday, April 8, 2019 8:10 PM
  • Just use the SMB client to copy the file. https://www.tldp.org/HOWTO/SMB-HOWTO-8.html 

    Or configure FTP on the Windows server and run the FTP client on the Linux machine.

    Or put Putty on the Windows machine and connect to SFTP on the Linux machine. https://www.maketecheasier.com/use-sftp-transfer-files-linux-servers/

    If your Windows machine is Server 2019 or win10 you can install OpenSSH. https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

    Monday, April 8, 2019 8:57 PM
  • Linux has shares (SMB shares).  Just copy the file from the windows share to the Linux share.

    Ask you Linux admins for help.  They will tell you what is available.


    \_(ツ)_/

    Monday, April 8, 2019 9:12 PM
  • how would i download the posh-ssh module and import it manually into a machine?
    Monday, April 8, 2019 9:15 PM
  • Just save it to a dvd and copy it to the machines as needed.


    \_(ツ)_/

    Monday, April 8, 2019 9:29 PM
  • Download it to the machine that you are currently using. Run mstsc and configure it to map your C drive when you RDP to the machine with no internet access. Then follow the install instructions.

    https://www.powershellgallery.com/packages/Posh-SSH/2.0.2

     
    Monday, April 8, 2019 9:36 PM
  • cani copy this folder to the destination machine ? and do i need to import it?

    Monday, April 8, 2019 9:42 PM
  • Please ask the author of you module how to use the module.  You can also try learning how to access shared files in Windows.

    "FilePath" is a file name and not a folder.


    \_(ツ)_/

    Monday, April 8, 2019 11:42 PM
  • This is not a scripting question but rather a "how do I copy file between hosts with different operating systems" question.

    Two common ways to do this are to use SMB and SSH file transfer mechanisms, as already noted.

    Other than to give that answer, this question is not within this forum's scope.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, April 9, 2019 7:55 PM