Solved

Permission from Folder

Posted on 2016-08-04
3
63 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
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:cmil
cmil 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 12

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 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