Solved

Permission from Folder

Posted on 2016-08-04
3
45 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Join & Write a Comment

OfficeMate Freezes on login or does not load after login credentials are input.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now