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):

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.instancename? Also this script should be executed on the server, not on the client machine.