Command to list single users that have special permissions to folders and sub

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Max Kozlov Max Kozlov 1 year, 6 months ago.

  • Author
    Posts
  • #32113

    Hi,

    For now i have following:

    get-childitem \\xxxxxfps001\Applications | where {get-aduser -filter {telephonenumber -like "*"}} | where{$_.psiscontainer} | foreach-object { get-acl $_.fullname | select path,owner,accesstostring}

    It kinda works – but is pretty slow. I want to list on single users (thats why i was using telephone as filter – as groups and special users dont have it).

    Any other idea how to do it efficiently?

  • #32115
    Profile photo of Noam lesnik
    Noam lesnik
    Participant

    Hi,

    you can try running it like this:

    $users = (get-aduser -filter {telephonenumber -like "*"}).sAMAccountName
    get-childitem \\xxxxxfps001\Applications | where{$_.psiscontainer} | get-acl | where {$_.Owner.split('\')[1] -iin $users}

    if you have users from multiple domains you check the ACL owner domain as well. i used the split function here to get only the username without the domain.

  • #32119

    It shows me this error:

    Unexpected token 'iin' in expression or statement.
    At line:1 char:110

    Unexpected token 'users' in expression or statement.
    At line:1 char:114

  • #32120
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    That's a type-o. Should be "-in" not "-iin", without the "" of course.

  • #32153

    $users = (get-aduser -filter {telephonenumber -like "*"}).sAMAccountName
    get-childitem \\xxxxxfps001\Applications | where{$_.psiscontainer} | get-acl | where {$_.Owner.split('\')[1] -in $users}
    You must provide a value expression on the right-hand side of the '-' operator.
    At line:3 char:110

    Unexpected token 'in' in expression or statement.
    At line:3 char:111

    Unexpected token 'users' in expression or statement.
    At line:3 char:114

    Something still wrong

  • #32155
    Profile photo of Max Kozlov
    Max Kozlov
    Participant

    $psversiontable.PSVersion.Major -eq 2 ?

    try to use $users -contains $_.Owner.split('\')[1] instead of $_.Owner.split('\')[1] -in $users

You must be logged in to reply to this topic.