Is there a PowerShell command that will execute a backup of all databases on a server?
Alternatively, can I call a stored proc from PowerShell (that will execute the backup)?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
It is possible, there are some pre-requisites you need to have installed (namely the Microsoft SQL Server 2005 Management Objects Collection) and theres quite alot of powersehll code needed to do it, however there are a number of articles out there that have it allready done for you. I have used this method successfully in the past.
You can use ADO.NET from PowerShell to execute a stored proc..
See this example.
There's functions for PowerShell-based SQL Server database backups included in the CodePlex project SQL Server PowerShell Extensions (SQLPSX). Take look at Invoke-SqlBackup or if you want to implement a full backup and maintenance routine take a look at the SQLMaint module.