Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNC/CIFS Share paths not working in linux version? #6629

Closed
thebtm opened this issue Apr 11, 2018 · 27 comments
Closed

UNC/CIFS Share paths not working in linux version? #6629

thebtm opened this issue Apr 11, 2018 · 27 comments
Labels
Hacktoberfest Potential candidate to participate in Hacktoberfest Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

Comments

@thebtm
Copy link

thebtm commented Apr 11, 2018

Steps to reproduce

#linux powershell
PS /> Set-Location //server/folder/                     
Set-Location : Cannot find path '//server/folder/' because it does not exist.
At line:1 char:1
+ Set-Location //server/folder/
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (//server/folder/:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
 
PS /> Set-Location \\server\folder\
Set-Location : Cannot find path '\\server\folder\' because it does not exist.
At line:1 char:1
+ Set-Location \\server\folder\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (\\server\folder\:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Expected behavior

#windows powershell 6.0
PS C:\Program Files\PowerShell\6.0.2> Set-Location \\server\folder\
PS Microsoft.PowerShell.Core\FileSystem::\\server\folder>
PS Microsoft.PowerShell.Core\FileSystem::\\server\folder> ls


    Directory: \\server\folder

PS Microsoft.PowerShell.Core\FileSystem::\\server\folder>

Actual behavior

its not connecting to the UNC/CIFS share on the linux version of powershell

Environment data

My CentOS 7 box does have the cifs-util installed to perform a mount -t cifs installed andIi can mount locally but looking to see if we can just open the connection to the share without having to mount anything.

#bash
[root@centos7 powershell]# dnf list installed | grep cifs
cifs-utils.x86_64                       6.2-10.el7                       @System
#powershell
> $PSVersionTable

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.1
PSEdition                      Core
GitCommitId                    v6.1.0-preview.1
OS                             Linux 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS Microsoft.PowerShell.Core\FileSystem::\\server\folder> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.2
PSEdition                      Core
GitCommitId                    v6.0.2
OS                             Microsoft Windows 10.0.14393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@MaximoTrinidad
Copy link

Think this is known issue posted sometime ago. I think it was posted as an issue with the New-PSDrive cmdlet no able to work with CIFS settings or something.
:)

@thebtm
Copy link
Author

thebtm commented Apr 11, 2018

I wasn't able to find that issue or i would have posted there. your welcome to combine the issues. I have a PowerShell script I tried running on the Linux version that pointed didn't save the file into the network share like it suppose.

@MaximoTrinidad
Copy link

I'm looking for it because I mention it long time ago. I'm using CIFS shared folders outside of PowerShell.
:)

@MaximoTrinidad
Copy link

Well! I guess I never did post nor comment about it.
:(

This feature could be useful if you can use the New-PSDrive to connect to an existing Shared folder.

@iSazonov iSazonov added Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc. labels Apr 12, 2018
@MaximoTrinidad
Copy link

MaximoTrinidad commented May 13, 2018

Well! Circling back to this issue.

I notice this issue has been open since 2016 from the original issue which has been closed without resolution. (#1409)

Any idea now that we are reaching RC status? This should have been fixed by now.
:)

@MaximoTrinidad
Copy link

So, why not allowing the following: (At least for "smbfs")

New-PSDrive -Name "Linux/UnixfolderToMount" -Root "\\Server\ShareFolder" -PSProvider "smb"  -Credentials UserID@Hostname

:)

@oskarm93
Copy link

I tried using New-PSDrive with -Root '\\hostname\sharename' on CentOS 7. Same error message.

@midacts
Copy link

midacts commented Jun 19, 2019

Spongebob-AFewMomentsLater

@keithallenjackson
Copy link

I'm currently trying to make our existing PowerShell 5 scripts compatible with PowerShell Core/6 and have ran into this issue on Mac. Windows PowerShell Core is able to connect to UNC (Samba) paths, but Mac PowerShell Core 6.2 cannot. It appears this issue has either been forgotten or is just not a priority. Has there been any work done to make this work?

@midacts
Copy link

midacts commented Jul 2, 2019

@SteveL-MSFT I pinged Chris Bergmeister in slack to see if this might be something that would be resolved in PS 7. He suggested I ping you on this issue to ask.

My team is looking to leverage PS 7 on linux to migrate our PS 5.1 code and build servers over to PS 7 running on Linux. This is one of the issues I've ran into hindering us from migrating off of PS 5.1.

@SteveL-MSFT
Copy link
Member

@midacts the problem is that the Windows file system inherently handles SMB/CIFS paths so there's no special handling by PowerShell. Linux/macOS does not. One option is to leverage smbclient on Linux. Or install OpenSSH on Windows and use SCP or SFTP across all your operating systems.

@midacts
Copy link

midacts commented Jul 5, 2019

It makes sense. I've used smbclient on linux machines before.
Thanks for the reply.

@soul4soul
Copy link

My team uses PowerShell on Windows to help manage our CI tasks. We are experimenting with it on Linux now with PS7. Not being able to use New-PsDrive on Linux to access a smb path sucks. Relatedly we noticed Restart-Computer doesn't work on Linux either.

Is there an easy way to determine the PowerShell commands that work on Linux or the limitations of the commands on different operating systems?

I'm looking at the help documentation for New-PSDrive and Restart-Computer. Neither of these commands mention this necessary information. Conceivable one could guess Restart-Computer won't work on Linux by reading the Notes section of the documentation...

@Christophoclese
Copy link

smbclient seems like a suitable workaround if you need to perform simple file transfers.

What about cmdlets like New-PSRepository? I'm not seeing a clear way to create repos or publish modules to a UNC/CIFS path unless you are on Windows.

Use smb (server) to mount those paths ahead of time?

@SteveL-MSFT
Copy link
Member

It may be possible to enable this by calling out to smbclient but would require that command to be installed.

@SteveL-MSFT SteveL-MSFT added Hacktoberfest Potential candidate to participate in Hacktoberfest Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors labels Oct 21, 2019
@Molochnikov
Copy link

Molochnikov commented Nov 25, 2020

So the year has passed without any implementation

@MunchyYDL
Copy link

Just ran into this now as well. I have been using Powershell Core 7 as a way to get my scripts to run cross-platform, so this is a bit of a snag. :(

@larsmaes
Copy link

larsmaes commented Mar 3, 2021

To bad this isnt implemented.. needed this for copying some file from a share in linux and to some work with it. now i need more tooling

@andyedison
Copy link

On top of it being very unfortunate that this ability doesn't exist for the mac and linux versions, but there is nary a mention of this in the documentation for New-PSDrive. We were moving forward with an implementation that used powershell on Linux and one of our use cases is mounting temporary windows shares. Imagine my surprise that it doesn't think any of our shares exist.

@godeater
Copy link

godeater commented Apr 7, 2022

And now we're yet another year later. No mention of a fix, and nothing in the documentation to say it doesn't work for non-windows platforms.

@LinuxBoi7777
Copy link

what's the point of bringing powershell to linux if you can't even use literally the most common task for system administrators to do inside of a org.

Even if it is a supper janky and very slow method of copying files, it would be great. having nothing is a joke.

@LinuxBoi7777
Copy link

LinuxBoi7777 commented Oct 14, 2022

OK i figured out a way to copy items from the powershell 7.2 linux to a windows smb share but it's hacky. Better than no option at all.

#wnsuring windows drive is mapped to linux
if(test-path "/mnt/win_share"){
     echo "Share drive exists, i will map to letter D"
     $D = "/mnt/win_share"
}else{
     #running bash command inside of a .ps1 file
     "mount -t cifs -o username=Administrator@domain.com,password=123 //10.151.150.35/smb_share /mnt/win_share" | bash
     $D = "/mnt/win_share"
}

#query items to copy
$Files2Copy = ((get-childitem /home/administrator)) | where-object{$_.LastWriteTime -lt ((get-date).AddDays(-30))}

#copy items command
foreach($file in $Files2Copy){
  copy-item ($file).FullName $D
}

"umount /mnt/win_share" | bash

basically we are piping a command line argument string into bash. This is not the intended way of normally doing things since new-psdrive is off the table, but at least we can get some milage.

I think the default behavior to map a drive in linux should do a synthetic mapping of the /mnt drive, just so system administrators don't need to research for hours to come up with a solution.

@hamaney
Copy link

hamaney commented Feb 18, 2023

Any updates?

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest Potential candidate to participate in Hacktoberfest Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Projects
None yet
Development

No branches or pull requests