After you start up PowerShell, you need to import sqlps module into PowerShell to manage SQL Server from PowerShell.
PS SQLSERVER:\> import-module ‘sqlps’
Ignore warning messages:
Once the module load is completed create a backup for a your database using a command like this:
PS SQLSERVER:\> backup-sqldatabase -serverinstance dn133004 -database model –
backupaction database -Backupfile “\\servername\sharedfolder\b.bak”
Backup actions : database ( for full backup) / log (for log backup)
Below are the PowerShell Cmdlets for backup and restore :
• Backup-SqlDatabase
• Restore-SqlDatabase
• Backup-ASDatabase
• Restore-ASDatabase
To view the data in Grid view using PowerShell:
PS SQLSERVER:\sql\dn133004\default> invoke-sqlcmd -query “select * from master.sys.sysaltfiles” |out-gridview