Home > Back-end >  Powershell copy file from domain server to workgroup shared folder
Powershell copy file from domain server to workgroup shared folder

Time:10-17

Current situation: We've got a domain with mostly Win Server 2022, including one database server. Next to that our backup server is in a different (accessible) VLAN, but did not join the domain (still in Workgroup). I've got a shared folder on our backup-server with permissions to Everyone.

Future situation: I would love to write a powershell-script that automatically sends file from our Database-server (in domain) to our backup server (workgroup).

I keep struggling with permissions and auomatically putting them into the PowerShell scripting ... Anyone has got a solution to this?

CodePudding user response:

You can authorize against the share with net-use first, then call your powershell

net use \\server\share /user:<domain\username> <password>

Or if you want to go powershell only, use the New-PSDrive cmdlet.
New-PSDrive -Name P -PSProvider FileSystem -Root \\Server01\Public -Credential user\domain -Persist

Hope this helps.

  • Related