# Unable to send files to shared location from SQL Server job

**URL:** <https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454>\
**Category:** PowerShell Help\
**Created:** [January 28, 2022, 8:10pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454 "2022-01-28T20:10:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [January 28, 2022, 8:10pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/1 "2022-01-28T20:10:21Z")

</div>

Team,

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”

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 28, 2022, 9:13pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/2 "2022-01-28T21:13:20Z")

</div>

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 ( **\</\>** ).

> [@Welcome to the new PowerShell Forums](https://forums.powershell.org/t/welcome-to-the-new-powershell-forums/7/6):
>
> How to format code in [PowerShell.org](http://PowerShell.org) forums. [Codeformatting\_1]

---

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [February 3, 2022, 8:09pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/3 "2022-02-03T20:09:55Z")

</div>

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’.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 3, 2022, 8:28pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/4 "2022-02-03T20:28:32Z")

</div>

Please format code AND error messages as code.

> [@powershell\_techie](#):
>
> 'Invalid Path: ‘\Server\Share’.

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

---

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [February 3, 2022, 9:04pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/5 "2022-02-03T21:04:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 3, 2022, 9:22pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/6 "2022-02-03T21:22:01Z")

</div>

> [@powershell\_techie](#):
>
> Not sure why error shows only one / but script has 2 // as shows below.

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.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [February 4, 2022, 12:58am UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/7 "2022-02-04T00:58:33Z")

</div>

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:

```auto
\\Server\Share\Folder

```

---

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [February 4, 2022, 3:25am UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/8 "2022-02-04T03:25:57Z")

</div>

Thank you all… it worked with below statement.

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

---

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [February 4, 2022, 3:28am UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/9 "2022-02-04T03:28:03Z")

</div>

Hi Olef,

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

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 4, 2022, 7:13am UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/10 "2022-02-04T07:13:49Z")

</div>

> [@powershell\_techie](#):
>
> 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. 😏

And BTW: My is Olaf. 🤨

---

<div class="post-metadata">

**Author:** ![powershell\_techie](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@powershell\_techie](https://forums.powershell.org/u/powershell_techie)\
**Post date:** [February 4, 2022, 1:22pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/11 "2022-02-04T13:22:37Z")

</div>

Sure, Thank you.

Padma

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:19pm UTC](https://forums.powershell.org/t/unable-to-send-files-to-shared-location-from-sql-server-job/18454/12 "2024-05-16T20:19:33Z")

</div>


