0

I am relatively new to Powershell, and I got a script to use to restore database in SQL Server 2019.

I was running this bottom Powershell script on my new VM, and got bottom error message.

This is Powershell script that I was running:

Get-ChildItem "F:\NH\WH_BEE_$(Get-Date -Format "yyyyMMdd")_*.bak" | `
Restore-DbaDatabase `
    -SqlInstance instanceName `
    -Database WH_BEE `
    -FileMapping @{
       "WH_Data1" = "F:\data\WH_BEE.MDF";
       "WH_Data2" = "F:\data\WH_BEE_1.NDF";
       "WH_Log" = "G:\log\WH_BEE.LDF"
    };

This is error message:

WARNING: [20:29:39][Restore-DbaDatabase] Failure | The network path was not found

I recently installed dbatools on this VM.

Am I missing anything on the script?

Or installation probably not done correctly?

To install dbatools, I just typed bottom on WindowsPowerShell as an Administrator.

 Install-Module dbatools

Update (8/24/2024):

enter image description here

11
  • I suspect you are not able to access the file location. If you open File Explorer and go to "F:\NH", do you see a WH_BEE_20240822_*.bak file there? Commented Aug 22, 2024 at 21:08
  • 3
    Does the SQL Server Service Account have access to those paths though? It doesn't matter if you do, the thing that matters is if SQL Server does (which for the default account is very limited). If F: is actually a network drive (I hope not as that's where you're restoring to), then that drive will not exist for the Service Account; mapped drives are specific to users. Use the UNC path and, again, ensure the Service Account has access to that path. Commented Aug 23, 2024 at 7:52
  • 1
    What did you put for instancename? Also this script should be executed on the server, not on the client machine. Commented Aug 23, 2024 at 11:02
  • 1
    The SQL Server Agent Account is the Service Account for the SQL Server Agent, @Java, not the data engine. You need to give permission to the SQL Server (Data Engine) Service Account. That will be whatever you set that to be when you installed/configured SQL Server. Commented Aug 24, 2024 at 16:20
  • 1
    What does your configuration manager tell you, @Java..? I can't tell you what you set your configuration to. Commented Aug 24, 2024 at 16:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.