tell me the easiest way to write to a smb file in powershell without mounting?

You could use the Windows’ net utility

net use \\server /user:domain\username password

Or use PowerShell cmdlet New-SmbMapping from the SmbShare module:

New-SmbMapping -RemotePath '\\server' -Username "domain\username" -Password "password"

After that, you can simply use the UNC path for writing to the file, for example with Out-File

"Your output" | Out-File "\\server\path\myfile.txt"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top