2012-03-21 58 views
0
$strComputer = "." 
$strInstanceName = "SQLSERVER2008" 
$wmi=Get-WmiObject -computerName $strComputer -namespace root\Microsoft\SqlServer\ComputerManagement10 -class FILESTREAMSettings -filter "InstanceName='SQLSERVER2008'" 
Write-Output $wmi.AccessLevel 
$wmi.EnableFILESTREAM(2, "SQLSERVER2008") 
$wmi=Get-WmiObject -computerName $strComputer -namespace root\Microsoft\SqlServer\ComputerManagement10 -class FILESTREAMSettings -filter "InstanceName='SQLSERVER2008'" 
Write-Output $wmi.AccessLevel 

我运行这个脚本,但它不起作用。 的$ wmi.AccessLevel之前运行$ wmi.EnableFILESTREAM后(1, “SQLSERVER2008”)仍然是0Powershell EnableFILESTREAM不起作用

+0

读到这里myabe可以帮助你http://blogs.msdn.com/b/sqlserverstorageengine/archive/2008/06/09/enabling-filestream-post-sql2008-setup-a-known-issue-在-SQL配置,manager.aspx – 2012-03-21 11:09:11

回答

1

尝试调用此:

EXEC sp_configure filestream_access_level, 2 
RECONFIGURE 

从PowerShell中。重要的部分是“重新配置”。

$ServerInstance = "SQLSERVER2008" 
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection 
$sqlConnection.ConnectionString = "Server=$ServerInstance;Database=master;Trusted_Connection=True;" 

$Command = $sqlConnection.CreateCommand() 
$Command.CommandText = "EXEC sp_configure filestream_access_level, 2; RECONFIGURE" 

$sqlConnection.Open() 
$Command.ExecuteNonQuery() | Out-Null 
$sqlConnection.Close() 
相关问题