Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Friday, February 3, 2012

How to extract the file permissions of every file and folder, and subfolder, inside of a share.

The objective of this one liner is to allow you to enumerate all the shares on a client. Then recurse through the files and folders to get the NTFS permissions on each.

Get-WmiObject Win32_Share | Select-Object Property Path | Get-ChildItem recurse | get-acl

To get only directorys:

Get-WmiObject Win32_Share | Select-Object Property Path | Get-ChildItem recurse | Where-Object {$_.mode match d} | get-acl

To only get information on files:

Get-WmiObject Win32_Share | Select-Object Property Path | Get-ChildItem recurse | Where-Object {$_.mode notmatch d} | get-acl

No comments: