title: Create Folder, Create AD Groups, Apply Groups to Folder and Set Permissions
body: <p>I'm trying to find a much cleaner way of creating a network share folder, creating an Active Directory Security group that matches the share, and then applying the levels of permissions to the folder all while asking the questions in the script.</p>
  
  <ul>
  <li>Create folder <code>D:\Test Share</code></li>
  <li>Share as Test Share</li>
  <li>Create AD Group <code>FS-TESTSHARE-R</code></li>
  <li>Create AD Group <code>FS-TESTSHARE-RW</code></li>
  <li>Apply Both groups to the new share folder</li>
  <li>Set Full Read permissions to <code>FS-TESTSHARE-R</code></li>
  <li>Set Full Read/Rights permissions to <code>FS-TESTSHARE-RW</code></li>
  <li>Set full access permissions to <code>Domain Admins</code></li>
  </ul>
  
  <p>This is what I have so far and am completely lost as to how to get the rest and make it work:</p>
  
  <pre><code>$Path = 'c:\TestShare'
  
  # create new folder
  $null = New-Item -Path $Path -ItemType Directory
  
  # get permissions
  $acl = Get-Acl -Path $path
  
  # add a new permission
  $permission = 'domain\FS-TESTSHARE-RW', 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
  $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permission
  $acl.SetAccessRule($rule)
  
  # set new permissions
  $acl | Set-Acl -Path $path
  </code></pre>