Red Gate forums :: View topic - Set Recovery Mode on a target database
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
Deployment Manager
Deployment Manager forum

Set Recovery Mode on a target database

Search in Deployment Manager forum
Post new topic   Reply to topic
Jump to:  
Author Message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Thu Apr 03, 2014 11:12 am    Post subject: Set Recovery Mode on a target database Reply with quote

Is it possible to set Recovery Mode on a database being deployed by Deployment Manager? Perhaps with a PowerShell script?

I would like to be able to automatically set our test databases in Simple Recovery Mode.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 593

PostPosted: Mon Apr 07, 2014 2:52 pm    Post subject: Reply with quote

Yes, this is possible. Powershell + SQLCMD is fully supported.

I'll take a very quick look at the powershell forum to see if there's anything already there.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 593

PostPosted: Mon Apr 07, 2014 3:00 pm    Post subject: Reply with quote

Couldn't find it on the forums but here's a simple example that should help:

https://community.rackspace.com/products/f/18/t/1630
Back to top
View user's profile Send private message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Sun Apr 20, 2014 9:20 pm    Post subject: Reply with quote

Thank you Chris,

Got a modified version of that sample from https://community.rackspace.com/products/f/18/t/1630 working in the PostDeploy.ps1 script of a Deployment Manager project.

I didn't get the script to work with string representations of the RecoveryModel options, but had to use the enum representation like so:

Code:
[Microsoft.SqlServer.Management.Smo.RecoveryModel]::Simple


And to apply SQL Server Authentication I had to add:

Code:
#This sets the connection to mixed-mode authentication
$smo.ConnectionContext.LoginSecure=$false;

#This sets the login name
$smo.ConnectionContext.set_Login("$databaseUserName");

#This sets the password
$smo.ConnectionContext.set_Password("$databasePassword")


after instantiating the $smo object.

Thanks for the help!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group