This topic contains 1 reply, has 2 voices, and was last updated by
September 14, 2017 at 6:00 pm #79789ParticipantPoints: 0Rank: Member
I'm a *nix guy, stuck in a windows world. So when I learned I could run Powershell on my beloved ubuntu box and admin my windows servers I had to give it a shot.
one of the first tasks, copy this file to that share... not a problem, lets use my new found powershell and
Copy-Item -Path //path/to/my/file -Destination //path/to/be/copied :enter
Copy-Item : Could not find a part of the path '/test/share/directory/'. At line:1 char:1 + Copy-Item -Path test -Destination //test/share/directory/ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
I cried myself to sleep that night, because I couldn't do a simple task like copy a file from one server to another.
enter good 'ole smbclient to save the day
smbclient -U username%password -W domain.tld //ip.of.the.server/share --directory directory/ -c "put test"
would it be possible to get Copy-Item to leverage this facility to complete this task?
October 3, 2017 at 2:37 pm #81155KeymasterPoints: 1,704Rank: Community Hero
In theory, yeah. I think the problem – and I'm not a Linux guy, so I'm guessing – is that while Windows has an SMB client running all the time, Linux doesn't. Copy-Item is just asking the underlying OS to handle the copy, so if the OS doesn't "know" how to handle an SMB path, it'll fail, and the error you're seeing is the result of that. Copy-Item is relatively "dumb" in that way – it doesn't know it needs to load a specific client or anything. Essentially, if cp can't do it, Copy-Item is likely to fail also. You'd need to somehow have an SMB client loaded and running before going into PowerShell to begin with.
The topic ‘Copy-Item on Linux’ is closed to new replies.