Windows Server 2012 SMB PowerShell

Windows Server 2012 provides a series of PowerShell cmdlets and WMI objects to manage the SMB shares as well as to manage access permissions to those shares. These new PowerShell cmdlets are aimed at both IT professionals and developers alike.

The following PowerShell cmdlets are available for SMB share management:

  • Get-SmbShare
  • New-SmbShare
  • Set-SmbShare
  • Remove-SmbShare

The following PowerShell cmdlets are available for SMB share access permission management:

  • Get-SmbShareAccess
  • Grant-SmbShareAccess
  • Revoke-SmbShareAccess
  • Block-SmbShareAccess
  • Unblock-SmbShareAccess

The SMB cmdlets are packaged up nicely into two modules called SmbShare and SmbWitness. They can be loaded by using the PowerShell command Get-Module -ListAvailable Smb* | Import-Module. However, if you simply start using the cmdlets from within PowerShell, the related modules will automatically be loaded for you.

To get a list of the available SMB PowerShell cmdlets, use the PowerShell command Get-Command -Module SMB* | Select Name.


Getting Help
You can get help within PowerShell, including a list of parameters for a specific cmdlet, by using the Get-Help cmdlet. For instance, if you want help creating a new SMB share, you can use the PowerShell command Get-Help New-SmbShare -Detailed.

The following are some common use cases for leveraging the SMB PowerShell cmdlets:

  • Managing SMB shares: New, Get, Set, Remove
  • Managing SMB share permissions: Get, Grant, Revoke, Block, Unblock

The following are some common operational tasks that you might carry out when managing SMB file shares:

  • Create a new file share: New-SmbShare -Name ShareName -Path C:FolderLocation
  • Get a list of existing file shares: Get-SmbShare
  • Change the configuration of an existing share: Set-SmbShare -Name ShareName -Description “ Hyper-V share”
  • Remove a file share: Remove-SmbShare -Name ShareName

The following are some common operational tasks that you might carry out when managing SMB share permissions:

  • Add permissions for a user when creating a file share: New-SmbShare -Name ShareName -Path C:FolderLocation -FullAccess UserName
  • Grant permissions for a user after the file share is already created: Grant-SmbShareAccess -Name ShareName -AccountName UserName -AccessRight Full
  • Get a list of permissions for a file share: Get-SmbShareAccess -Name ShareName
  • Revoke permissions for a user: Revoke-SmbShareAccess -Name ShareName -AccountName UserName
  • Block a specific user from a file share: Block-SmbShareAccess -Name ShareName -AccountName UserName
  • Unblock a specific user from a file share: Unblock-SmbShareAccess -Name ShareName -AccountName UserName
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.115.166