Unable to send files to shared location from SQL Server job


I’m using below script from SQL Job to send configuration file to Shared location. This gives error invalid path. Can you please help on this?

Export-Dbaspconfigure -SqlInstance SQLInstanceName -path “\Sharedlocation\folder”

Below script is working from SQL Server job.

Export-Dbaspconfigure -SqlInstance SQLInstanceName -path “D:\folder”

The syntax for an UNC path is “\\Server\Share”. If it’s not a copy and paste error or a typo just here in your question you forgot a backslash at the front of your UNC path.

BTW: When you post code or sample data or console output please format it as code using the preformatted text button ( </> ).

Hi Olaf,

Here is the error and I tried with \ as well infront of the path.

A job step received an error at line 91907 in a PowerShell script. The corresponding line is ’ $null = New-Item -ItemType Directory -Path $Path -Force
'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Invalid Path: ‘\Server\Share’.

Please format code AND error messages as code.

hmmmm … I don’t know how obvious something has to be. It is not '\Server\Share'. It has to be '\\Server\Share'.

Not sure why error shows only one / but script has 2 // as shows below.

Export-Dbaspconfigure -SqlInstance InstanceName -path \\Server\share

This is the script trying to use from SQL Job and giving error as mentioned in previous response.
Can you please help?

That’s why I asked you (twice) to format your code or error messages as code in the forum … and you’re still ignoring it.

If PowerShell claims the path to be invalid you will have to figure out why. There’s no way we can help you in a froum without seeing your actual script and your actual environment.

Also a point of note, you are NOT giving it a folder path … you are just providing the Share path. You may not have root level access to the share top level.

You may need something like:


Thank you all… it worked with below statement.

Powershell.exe -command “Export-Dbaspconfigure -SqlInstance InstanceName -path \\server\share”

Hi Olef,

Sorry, I think I’m not sure what is formatting code? Will check on it.

Just follow the link I shared in my first answer. It’s not rocket science. :smirk:

And BTW: My is Olaf. :face_with_raised_eyebrow:

Sure, Thank you.