在我们配置镜像的先决条件是:数据库镜像需要的数据库完全恢复模式,下面用powershell更改吧。
在这篇文章中,我们将看到我们如何可以检索数据库恢复模式设置为何模式,然后将其设置为完全恢复模式。
根据实验需要,我们可以得到一个已经默认的SQL数据库恢复模式设置为数据库对象属性。
1
2
3
4
5
6
7
8
9
10
11
12
13
|
Add-Type
-AssemblyName
"Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
Add-Type
-AssemblyName
"Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
$conn
=
New-Object
Microsoft.SqlServer.Management.Common.ServerConnection
-ArgumentList
$env:ComputerName
$conn
.applicationName =
"PowerShell SMO"
$conn
.ServerInstance =
".\SQLEXPRESS"
$conn
.StatementTimeout = 0
$conn
.Connect()
$smo
=
New-Object
Microsoft.SqlServer.Management.Smo.Server
-ArgumentList
$conn
$smo
.Databases[
"MyDB"
] | Select Name, RecoveryModel
|
这个属性可以进行修改,最后可以以将数据库设置为完全恢复模式。
假设MYDB是简单恢复模式中,我们可以改变property(属性)。
1
2
|
$smo
.Databases[
"MyDB"
].RecoveryModel =
"Full"
$smo
.Databases[
"MyDB"
].Alter()
|
怎么样简单吧?
好了,我们说说powershell 4.0吧,
哦,不能说是正式版,这次微软更新后 出现了预览版的powershell4.0
也出现了 windows 管理框架( WMF) 4.0 预览版 windows framework 4.0
可以装在windows server2008R2 SP1 或者windows server 2012 windows 7
WMF 4.0 预览版更新版本特点
Windows PowerShell
Windows PowerShell ISE
Windows PowerShell Web Services (Management OData IIS Extension)
Windows Remote Management (WinRM)
Windows Management Infrastructure (WMI)
非常遗憾的是这个预览版不能装在windows 8 上
大家安装前不要忘记检查更新说明,理解如何使用(DSC)指南
此次更新的powershell 4.0 和其他WMF 4.0功能
windows server2012R2预览
好了先介绍到着 后期Cantgis会和大家一起 学习预览版的内容。
本文转自cantgis 51CTO博客,原文链接:http://blog.51cto.com/cantgis/1240792,如需转载请自行联系原作者