Thor Logo dbatools

Disable-DbaFilestream

View Source
Stuart Moore (@napalmgram) , Chrissy LeMaire (@cl)
Windows, Linux, macOS

Synopsis

Disables SQL Server FileStream functionality at both the service and instance levels

Description

Disables the FileStream feature completely by setting the FilestreamAccessLevel configuration to 0 (disabled) and modifying the corresponding Windows service settings. This is useful when FileStream was previously enabled but is no longer needed, during security hardening, or when troubleshooting FileStream-related issues.

The function handles both standalone and clustered SQL Server instances, automatically detecting cluster nodes and applying changes across all nodes. Since disabling FileStream requires changes at both the SQL instance configuration level and the Windows service level, a SQL Server service restart is required for the changes to take effect.

By default, the function will prompt for confirmation before making changes due to the high impact nature of this operation. Use -Force to bypass confirmation and automatically restart the SQL Server service, or run without -Force to make the configuration changes and restart manually later.

Syntax

Disable-DbaFilestream
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Credential] <PSCredential>]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Disable-DbaFilestream -SqlInstance server1\instance2

Prompts for confirmation. Disables filestream on the service and instance levels.

Example: 2
PS C:\> Disable-DbaFilestream -SqlInstance server1\instance2 -Confirm:$false

Does not prompt for confirmation. Disables filestream on the service and instance levels.

Example: 3
PS C:\> Get-DbaFilestream -SqlInstance server1\instance2, server5\instance5, prod\hr | Where-Object InstanceAccessLevel -gt 0 | Disable-DbaFilestream -Force

Using this pipeline you can scan a range of SQL instances and disable filestream on only those on which it’s enabled.

Required Parameters

-SqlInstance

The target SQL Server instance or instances. Defaults to localhost.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByPropertyName)
Default Value

Optional Parameters

-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByPropertyName)
Default Value
-Credential

Login to the target server using alternative credentials.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByPropertyName)
Default Value
-Force

Bypasses confirmation prompts and automatically restarts the SQL Server service to apply FileStream configuration changes immediately.
Without this parameter, the function makes configuration changes but requires you to manually restart the SQL service later for changes to take effect.
Use with caution in production environments as it causes service downtime during the restart.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

Shows what would happen if the command runs. The command is not run unless Force is specified.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

Prompts you for confirmation before running the command.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value