Creating SHARE on powershell & Setting ACL on a File or Directory in Powershell


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 -> ( ❤

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

very attractive!!!

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 = “\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



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s