Hi guys & ladies ( Little ironic mode activated in this post )
Today we gonna learn how to create powershell script that creates a Share 😉 We all already know that is some more complicated than the GUI way … but maybe someday if a storm breaks all your servers … your company doesn’t have money to buy a new suite … and you have to fight with Core servers… maybe you are bored… I don’t know but here is anyway the stuff!!
0. Open Powershell :D:D
1. Create the folder ( important :P)
mkdir … “path” here little history of mkdir -> (http://en.wikipedia.org/wiki/Mkdir) ❤
2. Share the folder ( owner permissions inherited ofc)
New-SmbShare -Name Xfer -Path c:\xfer
as you can see with the command get-acl “path” we can watch in this powerful view blue… and lovely … wow !!
but there’s more if you put get-acl “path” |select -expand access you will see a SUPER NICE TABLE STYLE 80’s
3.The Funny part : Create the super-script & run it ( for example I’m gonna stablish full control to the student1 and please don’t think about best security practices… this is an example 😛 )
$acl = Get-Acl c:\xfer
$permission = “kerrigan.com\student1″,”FullControl”,”Allow”
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl | Set-Acl c:\xfer
4. You can see i’m rocking it ( this is proved with the step 2 command get-acl with the format ..)
5. The world is yours