Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.



PowerShell Get-Acl

PowerShell Script Files - Get-Acl

From a strategic point of view Get-Acl (Access Control List) is a stepping-stone to changing permissions with Set-Acl.  When learning about Get-Acl select a file rather than a folder, those SID numbers can be so meaningless.

 ♣

Example 1: Get-Acl Owner Check

I have chosen the Windows log files as vehicle to test Get-Acl.

# PowerShell Get-Acl Windows Log files
Clear-Host
$Files = "C:\Windows\*.log"
Get-Acl  $Files | Format-Table -property PSPath, owner

Learning Points

Note 1:  The reason that I used the variable $Files is that I want to remind you to change the value for the path before running this script on your machine.

Research Get-Acl Properties

Format-Table is of great help with Get-Acl.  I recommend researching the precise spelling of the various properties by appending Get-Member thus:

# PowerShell Get-Acl Properties
Clear-Host
$Files = "C:\Windows\*.log"
Get-Acl  $Files | Get-Member -memberType *Property

Note 2: -memberType *Property filters out methods and shows just the various properties.  For example PSChildName may be better than PSPath.

Note 3:  Actually, any file will do to check the properties supported by Get-Acl.

Guy Recommends: Permissions Analyzer - Free Active Directory ToolFree Permissions Monitor

I like the Permissions Monitor because it enables me to see quickly WHO has permissions to do WHAT.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource.

Download Permissions Analyser - Free Active Directory Tool

Example 2: Get-Acl to Find a Particular Owner

The reasons that I chose -match 'Administrator' is that every Windows operating system has Administrators, and I don't know the names of your users.

# PowerShell Get-Acl Find Owner = Administrator
Clear-Host
$Files = "C:\Windows\*.log"
Get-Acl $Files | Where {$_.Owner -match 'Administrator'} `
| Format-Table -property PSChildName, owner -auto

Note 4:  I recommend that you change 'Administrator' to the name of users on your computer.  Furthermore, I you take my advice then you may wish to change the value of $Files to "C:\Windows\Users\"PowerShell Get-Acl cmdlet

Note 5: Pure PowerShell syntax include ` backtick for word-wrap (|) for piping and -auto to concentrate the columns.

Background Research

In addition to pure PowerShell Get-Acl research I strongly recommend that open Windows Explorer and look at not only the location of the files, but also at the permissions.

If you right-click any file or folder, select properties and check the permissions. For further detail click Edit, see screenshot to the right.

Another useful technique is to use CACLS

Research Get-Acl Parameters

# PowerShell Get-Acl Parameters
Clear-Host
Get-Help Get-Acl -full

Checking the help file will reveal useful parameters, for instance the -audit switch maybe useful for your task.  In addition to the file system you can also use Get-Acl to list permissions on registry keys.

See more on the useful Solarwinds Free Permissions Analyzer.

Researching Similar PowerShell Content Cmdlets

# PowerShell Content Cmdlet Research
Clear-Host
Get-Command -noun Acl

This reveals the sister command Set-Acl.  Incidentally, many of PowerShell's Get verbs also have a 'Set' companion cmdlet. 

Summary of PowerShell's Get-Acl

Get-Acl is rather different from the mainstream PowerShell cmdlets.  What you learn about 'Get' you can apply to setting permissions with Set-Acl.

If you like this page then please share it with your friends

 


See more PowerShell share examples including WMI

PowerShell WMI   • Win32_Share   • WMI Shares   • Query

Get-Acl  • PowerShell Error Codes   • Win32_ComputerSystem

Please email me if you have a example scripts. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Custom Search

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.

Fortunately, Solarwinds have created the Free WMI Monitor so that you can actually see and understand these gems of performance information.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

 

Home Copyright © 1999-2012 Computer Performance LTD All rights reserved

Please report a broken link, or an error.