Store SQL Server Files on SMB File Shares: A Beginner’s Guide

By Pinal Dave on March 9, 2015


One recent enhancement is the ability to store SQL Server files on SMB File Shares. In this article, we will look at Windows Server 2012’s Windows PowerShell cmdlets and WMI objects to manage SMB File Servers and SMB File Shares. These new tools are aimed at both system administrator and developers, and can be accessed to:

  • Use the PowerShell command line to manage and monitor File Servers and File Shares.
  • Write scripts that automate common File Server administrative tasks.
  • Leverage existing PowerShell skills.
  • Integrate with related PowerShell-managed components (network, block storage, cluster).

Easy Configuration Steps

The SMB PowerShell cmdlets and WMI objects are available by default in Windows Server 2012 and can be found in Windows 8 clients too. There is no need to install components, roles, role services or features to use this. The SMB cmdlets are packaged into two modules called SmbShare and SmbWitness. These modules are automatically loaded whenever you refer to any of the cmdlets included. No upfront configuration is required.

Optionally, you can load these modules manually using the following PowerShell cmdlet:

Import-Module Smb*

You can list all cmdlets in the SMB PowerShell modules using the following PowerShell cmdlet:

Get-Command –Module Smb*

A sample output of the same would look like:

Pinal Dave PowerShell Output Example

You can obtain information about any PowerShell cmdlet (including a list of parameters) by using the Get-Help cmdlet. For example, to get help for the Get-SmbShare cmdlet, use the following PowerShell cmdlet:

Get-Help Get-SmbShare

Here are some simple steps for creating a SMB share for SQL Server use. Though they are simple steps, these are good to know.

  • Create new file share
New-SmbShare –Name ShareName –Path C:\LocalSMBFolder
  • Get a list of existing file shares
Get-SmbShare
  • Remove a file share
Remove-SmbShare –Name ShareName

 

SMB PowerShell Cmdlet List

Here is the list of SMB PowerShell cmdlets in Windows Server 2012, grouped by function.

Share
·         Get-SmbShare
·         New-SmbShare
·         Set-SmbShare
·         Remove-SmbShare
Share access
·         Get-SmbShareAccess
·         Grant-SmbShareAccess
·         Revoke-SmbShareAccess
·         Block-SmbShareAccess
·         Unblock-SmbShareAccess
Server session and open file
·         Get-SmbSession
·         Get-SmbOpenFile
·         Close-SmbSession
·         Close-SmbOpenFile
Client mapping and connection
·         Get-SmbMapping
·         New-SmbMapping
·         Remove-SmbMapping
·         Get-SmbConnection
Network interface
·         Get-SmbServerNetworkInterface
·         Get-SmbClientNetworkInterface
·         Get-SmbMultichannelConnection
·         Update-SmbMultichannelConnection
Client and server configuration
·         Get-SmbClientConfiguration
·         Set-SmbClientConfiguration
·         Get-SmbServerConfiguration
·         Set-SmbServerConfiguration

This article provides just a quick overview of what is available in SMB shares.  I would love to hear from you if you have ever utilized SMB Shares in your environments before. What are all the use cases you use in your setup?

Related Posts

Leave a Reply