#PSTip How to create a share in Windows Server 2012

Quite easy, with a one-liner. Windows Server 2012 provides Windows PowerShell cmdlets and WMI objects to manage SMB file servers and SMB file shares. The SMB cmdlets are packaged into two modules called SmbShare and SmbWitness. These modules are automatically loaded (thanks to new module auto-loading feature) whenever you refer to any of the contained cmdlets. No upfront configuration is required. (Note: Check the output of the Get-Module command before and after you run the following one-liner to see that SmbShare module is loaded behind the scenes.)

New-SmbShare –Name MyShare –Path C:\Test –Description ‘Test Shared Folder’ –FullAccess Administrator –ReadAccess Everyone

About the author: Aleksandar Nikolic

Aleksandar is a PowerShell MVP and a co-founder of PowerShell Magazine. He is a frequent speaker at the conferences and participates regularly in IT Pro user groups worldwide. Recently, Aleksandar co-authored the highly respected Administrator’s Guide to Windows PowerShell Remoting. Follow him on Twitter at @alexandair

Related Posts