Solved

Permission from Folder

Posted on 2016-08-04
3
71 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

679 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