Avatar of creative555
creative555
 asked on

Help with the script

Hello,
I need help with the following script. This script is working great for us except I would like to be able to tell if the IdentityREference is a USER or a GROUP. I would like the script to output everything the same way it is plus add an additional column which would say if it is a USER or a GROUP. Thank you so much.



# Include only folders from the root path
Get-ChildItem "C:\installs" -Recurse | ?{ $_.PsIsContainer } | %{
  $Path = $_.FullName

  (Get-Acl $Path).Access | Select-Object `
    @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
    InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited
} | Export-CSV "Permissions.csv"
PowershellVB ScriptScripting Languages

Avatar of undefined
Last Comment
creative555

8/22/2022 - Mon
YZlat

you can use $object.Type property

try something like:

 (Get-Acl $Path).Access | Select-Object `
     @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
     InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited, $_.Type
 } | Export-CSV "Permissions.csv"

Open in new window

creative555

ASKER
I tried and it didn't work. I got the error
invalid argument

System.Management.Automation.ScriptBlock}. 
At C:\scripts\GET-NTFSpermissions-Test.ps1:5 char:26 
+ (Get-Acl $Path).Access | Select-Object ` 
+                          ~~~~~~~~~~~~~~~ 
    + CategoryInfo          : InvalidArgument: (:) [Select-Object], NotSupportedException 
    + FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.Sele 
   ctObjectCommand
YZlat

remove the ` after Select-Object
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
creative555

ASKER
Still getting an error
+                                                ~ 
Missing argument in parameter list. 
    + CategoryInfo          : ParserError: (:) [], ParseException 
    + FullyQualifiedErrorId : MissingExpressionAfterToken
creative555

ASKER
Here is the entire script that I am trying

# Include only folders from the root path
Get-ChildItem "c:\installs" -Recurse | ?{ $_.PsIsContainer } | %{
  $Path = $_.FullName

(Get-Acl $Path).Access | Select-Object
     @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
     InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited, $_.Type
} | Export-CSV "Permissions-Test.csv"
ASKER CERTIFIED SOLUTION
footech

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
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.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
creative555

ASKER
oh. Ok. I thought it would be too difficult. WE will use the excel to do it then. THank you.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.