How to mount a Windows UNC Path on ubuntu using PowerShell Core

be flag

Background: I have an ubuntu machine that hosts a couple applications that I am in charge of and I want to automate the backup of the database that powers these applications. I noticed that PowerShell is now cross platform, so I figured a simple script to run mysql dump and then move the dump file to a different server would fill my needs exactly.

Unfortunately, I seem to be stuck at mounting a temporary PS drive.

I did a ping test so the two servers can communicate with each other, however the log on credentials for the ubuntu machine is different than what the windows host would expect. in the below setup I double checked username and password, they are correct.

$user = "domain\username"
$pass = ConvertTo-SecureString -String "my password"  -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
New-PSDrive -Name "SQL Backups" -PSProvider "FileSystem" -Root "\\server\folder" -Credential $cred

error response:New-PSDrive: The specified drive root "\\server\folder" either does not exist, or it is not a folder

I know the folder/path exists as I can pull it up on a windows machine through file explorer.

Should/is it possible to move a file from an Ubuntu host to a Windows host with PowerShell core installed on the former? Or am I going down a rabbit hole?

PSVersion: 7.2.1

PSEdition: Core

Massimo avatar
ng flag
Can the Linux machine resolve the Windows server's name? Can you connect to the shared folder from the Linux machine using some other tool than PowerShell?
be flag
@Massimo I am not exactly sure how to test that. I did do a ping from the Linux machine to windows machine using the windows FQDN and got results. If you have another way to test that without any 3rd party tool or package I would be willing to give it a try.
Massimo avatar
ng flag

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.