Link to home
Create AccountLog in
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"
Avatar of YZlat
YZlat
Flag of United States of America image

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

Avatar of creative555
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
remove the ` after Select-Object
Still getting an error
+                                                ~ 
Missing argument in parameter list. 
    + CategoryInfo          : ParserError: (:) [], ParseException 
    + FullyQualifiedErrorId : MissingExpressionAfterToken
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
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
oh. Ok. I thought it would be too difficult. WE will use the excel to do it then. THank you.