troubleshooting Question

Folder Audit - Is user or group

Avatar of tonelm54
tonelm54 asked on
PowershellActive Directory
3 Comments1 Solution21 ViewsLast Modified:
With the help of several forums, Ive written a script which audits a folder, and dumps out the permissions of files and folders:-
$FolderPath = Get-ChildItem -Directory -Path "C:\temp" -Recurse -Force
$Output = @()
ForEach ($Folder in $FolderPath) {
    $Acl = Get-Acl -Path $Folder.FullName
    ForEach ($Access in $Acl.Access) {
        $Properties = [ordered]@{'Type'='Folder';'Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
        $Output += New-Object -TypeName PSObject -Property $Properties            

$FilesPath = Get-ChildItem -File -Path "C:\temp" -Recurse -Force
ForEach ($File in $FilesPath) {
    $Acl = Get-Acl -Path $File.FullName
    ForEach ($Access in $Acl.Access) {
        $Properties = [ordered]@{'Type'='File';'Name'=$File.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
        $Output += New-Object -TypeName PSObject -Property $Properties            

$Output | Out-GridView

Open in new window

The only bit Im stuck with now is to test weather $Access.IdentityReference is in reference to a user or a group.

I know how to add in the variable, but dont know how to test, as looking at the object $Access doesnt tell me if its a group or user.

Any suggestions?
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004