Solved

Permission from Folder

Posted on 2016-08-04
3
75 Views
Last Modified: 2016-08-04
I need help is possible save the users list with permission and a folder?


Example

Folder 1

Permissions tab
user1
user2
user3


I nee save in save in a list the name of the folder and which user are in the permissions tab
0
Comment
Question by:PLCITS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Assisted Solution

by:Benjamin Voglar
Benjamin Voglar earned 125 total points
ID: 41742439
you can do it with powershell:

get-acl c:\it | select -expand access | ft

change c:\it with your path.

you can save the result in to a file:

get-acl c:\it | select -expand access | export-csv c:\it\list.csv
0
 
LVL 1

Assisted Solution

by:Christopher Milligan
Christopher Milligan earned 125 total points
ID: 41742458
I user a powershell script for this

[cmdletbinding()]

param([Parameter(ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True)]$Computer = '[b][u]COMPUTER NAME HERE[/u][/b]') 

$shares = gwmi -Class win32_share -ComputerName $computer | select -ExpandProperty Name 
 
foreach ($share in $shares) { 
    $acl = $null 
    Write-Host $share -ForegroundColor Green 
    Write-Host $('-' * $share.Length) -ForegroundColor Green 
    $objShareSec = Get-WMIObject -Class Win32_LogicalShareSecuritySetting -Filter "name='$Share'"  -ComputerName $computer
    try { 
        $SD = $objShareSec.GetSecurityDescriptor().Descriptor   
        foreach($ace in $SD.DACL){  
            $UserName = $ace.Trustee.Name     
            If ($ace.Trustee.Domain -ne $Null) {$UserName = "$($ace.Trustee.Domain)\$UserName"}   
            If ($ace.Trustee.Name -eq $Null) {$UserName = $ace.Trustee.SIDString }     
            [Array]$ACL += New-Object Security.AccessControl.FileSystemAccessRule($UserName, $ace.AccessMask, $ace.AceType) 
            } #end foreach ACE           
        } # end try 
    catch 
        { Write-Host "Unable to obtain permissions for $share" } 
    $ACL 
    Write-Host $('=' * 50) 
    } # end foreach $share

Open in new window

0
 
LVL 13

Accepted Solution

by:
Dustin Saunders earned 250 total points
ID: 41742460
I recently answered a similar question, which has the code you are looking for.

See below code:
$OutFile = "C:\test\output.csv"
$LookFolder = "C:\test"

function getACL($Folders, $type)
{
    foreach ($Folder in $Folders){
	$ACLs = get-acl $Folder.Path | ForEach-Object { $_.Access  }
	Foreach ($ACL in $ACLs){
	$OutInfo = $Folder.Path + "," + $ACL.IdentityReference  +  "," + $ACL.IsInherited # Additional options:: + "," + $ACL.InheritanceFlags +"," + $ACL.AccessControlType + "," + $ACL.PropagationFlags
	Add-Content -Value $OutInfo -Path $OutFile
	}}
}

$nifolders = Get-ChildItem $LookFolder -recurse | ?{$_.PSIsContainer} | Select @{Name='Path';Expression={$_.FullName}},@{Name='InheritedCount';Expression={(Get-Acl $_.FullName | Select -ExpandProperty Access | Where { $_.IsInherited }).Count}} | Where { $_.InheritedCount -eq 0} | Select Path
$ifolders = Get-ChildItem $LookFolder -recurse | ?{$_.PSIsContainer} | Select @{Name='Path';Expression={$_.FullName}},@{Name='InheritedCount';Expression={(Get-Acl $_.FullName | Select -ExpandProperty Access | Where { $_.IsInherited }).Count}} | Where { $_.InheritedCount -gt 0} | Select Path

getACL($ifolders)
getACL($nifolders)

Open in new window


Where $lookFolder is the root you want to see.  This will show who has membership to the folder and if the folder has inheritance enabled.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question