#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
#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>
its not connecting to the UNC/CIFS share on the linux version of powershell
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
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.
:)
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.
I'm looking for it because I mention it long time ago. I'm using CIFS shared folders outside of PowerShell.
:)
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.
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. (https://github.com/PowerShell/PowerShell/issues/1409)
Any idea now that we are reaching RC status? This should have been fixed by now.
:)
So, why not allowing the following: (At least for "smbfs")
New-PSDrive -Name "Linux/UnixfolderToMount" -Root "\\Server\ShareFolder" -PSProvider "smb" -Credentials UserID@Hostname
:)
I tried using New-PSDrive
with -Root '\\hostname\sharename'
on CentOS 7. Same error message.
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?
@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.
@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.
It makes sense. I've used smbclient on linux machines before.
Thanks for the reply.
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...
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?
It may be possible to enable this by calling out to smbclient but would require that command to be installed.
Most helpful comment
It may be possible to enable this by calling out to smbclient but would require that command to be installed.