I’m trying to take backup of a database, but it keep saying this below. What am I doing wrong?
rei-epicor-db is the hostname of the server that have the database
This YouTube video is my reference Powershell To Back up SQL Server Database
Backup-SqlDatabase : Failed to connect to serve
At line:1 char:1
+ Backup-SqlDatabase -ServerInstance $Server -D
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:)
+ FullyQualifiedErrorId : Microsoft.SqlServ
agement.PowerShell.BackupSqlDatabaseCommand
This is my PowerShell script
$Server = "REI-Epicor-db\SQLSERVER2016"
$Database = "EpicorERPPilot"
$BackupFolder = "C:\Backup"
New-Item -Path "C:\Backup" -ItemType Directory
$DT = Get-Date -Format MM-dd-yyyy
$FilePath = "$($BackupFolder)$($Database)_db_$($dt).bak"
But if I do this, I’m able to see the database info. I’m not passing the -credentials here either.
Get-SqlDatabase -ServerInstance 'rei-epicor-db'