Skip to main content

PowerShell get folder security settings




How to check folder security settings?

How to check folder security permissions?

A lot of ways to do it, one is to use the graphical interface right click on the folder, click on properties, click on the security tab and it will show user accounts that is able to access the folder.

PowerShell scripting also provides a way to automate this process.
To determine or check the folder security settings and list whose user accounts is able to access the folder.

Using the graphical interface is quite easy to check the user account that has access or permissions to a folder. To provide documentation or listing then a screen shot of the window is needed.

For PowerShell, the permission, the access rights can be exported to a text file, CSV file or other preferred format for documentation or record purposes.

If need to check on a remote server or computer PowerShell will be able to run a query quite efficiently, as long as proper credentials is used to run the script.

Here's the script on how to query folder permissions on a remote shared folder.

(Get-Acl -LiteralPath '\\server_500\500_data\poles_folder').Access

It's a one liner command but the output is very useful.

Sample output:
FileSystemRights  : Modify, Synchronize
AccessControlType : Allow
IdentityReference : server_500\Sec_500
IsInherited       : False
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : None

FileSystemRights  : ReadAndExecute, Synchronize
AccessControlType : Allow
IdentityReference : server_500\user_01
IsInherited       : False
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : None

FileSystemRights  : Modify
AccessControlType : Deny
IdentityReference : server_500\denied_group
IsInherited       : False
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : None

FileSystemRights  : FullControl
AccessControlType : Allow
IdentityReference : server_500\Admin_500
IsInherited       : False
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : None

To query a local path just specify the path like or replace the UNC path:

(Get-Acl -LiteralPath 'E:\500_data\poles_folder').Access

This command below shows user accounts which have access to the folder and also the owner.

Get-Acl  'e:\mountain_pictures'  |  ft -Wrap

To discover or query a single user account, whether the account has access or permission to a particular folder, run the script below:

(Get-Acl -LiteralPath 'E:\trival_pics').Access | where IdentityReference -like "*John*"

Above command filters the output to the queried user which is "John"

Sample output: (query for a single user)

FileSystemRights  : FullControl
AccessControlType : Allow
IdentityReference : server_500\John Simon
IsInherited       : True
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : None


Till next time..Cheers.. Hope it helps..

Comments

Popular posts from this blog

Copy a single file using robocopy

Copy a single file using robocopy from a local folder to a shared folder on the network.
A simple rule of thumb before any disaster strike, don't interchange the source and the destination.

If source and destination is mistakenly reverse, files might get overwritten. To avoid any loss of data do a test with a dummy file to ensure things work perfectly.
Robocopy [source][destination]   [file to be copied]
robocopy c:\local_c_folder  \\PC_network\shared_folder   file_to_be_copied_xx.txt
The command will be completed successfully provided the network access right has no issues.

Robocopy works quite good on large files. A simple copy or xcopy command will also work but the speed might vary.

Robocopy is free it can be accessed from command line. No need to install the resource kit tool if the operating system is Windows 7 or newer version.

Copy files with selected file extension using PowerShell and Robocopy:

$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolde…

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username.
WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided.
Why would you need a command line tool if there’s a GUI to check?
If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username.
If you have remote computers, you need to delegate someone in the remote office or location to check.
Or you can just write a batch file or script to automate the task.
Here’s the code below on how get computer model, manufacturer and the username.
Open an elevated command prompt and type:
wmic computersystem get "Model","Manufacturer", "Name", "UserName"
Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name.
A sample output below will be generated if the co…