Creating a File Share with PowerShell and Windows Server Core

Share on:

Sometimes you just need to create a file share.

With Windows Server Core, you don’t have all the old GUI tools that we’re all used to. So you have to make do with PowerShell and the old fake DOS prompt. Fortunately, with a little help, it’s pretty easy.

First, create the folder you want to share. In this case, c:\share

Next, modify the ACL to grant the DOMAIN\File Server Admins group full control

1$sharepath = "c:\share"<br />
2$Acl = Get-ACL $SharePath<br />
3$AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("DOMAIN\File Server Admins","full","ContainerInherit,Objectinherit","none","Allow")<br />
4$Acl.AddAccessRule($AccessRule)<br />
5Set-Acl $SharePath $Acl

Finally, create the share and grant everyone full access.

1NET SHARE sharename=c:\share "/GRANT:Everyone,FULL"

Done.