Saturday, May 23, 2015

Creating a file share using PowerShell

I am always looking for easier ways to automate operations that I perform routinely and one of the things that I always have to do when I am setting it up servers is to create file shares.

Well, in the past, I have always used the net share command, but since this does not always work reliably, I was hoping for a better way to accomplish this using PowerShell.

Fortunately, I found this article which describes just that!!

Of course, I wanted to modify this script to suit my needs, so I modified it in the following manner based on the following TechNet article:

$FileSharePath = "C:\MyShare"
$FileShareName = "MyShare"
$UserGroups = "Administrators"
$ComputerName = $env:COMPUTERNAME
$ShareAccess = ".\$UserGroups"
New-SmbShare -Name $FileShareName -Path $FileSharePath -FullAccess $ShareAccess -Confirm:$false

No comments:

Post a Comment