Today is: 6 September, 2010

powershell

Powershell function to remove empty directories

I created the following recursive function to delete empty directories. I made it recursive instead of using the built-in recursive argument because I was working with large file system, and the file and directory "counting" that the recursive flag does was a bit cumbersom. The force flag on the get-childitem cmdlet will cause the cmdlet to discover hidden files.

Adding rights to a file or folder with PowerShell

Pretty straight forward example and reference for adding rights to a folder or file with PowerShell.

Example

$AccessControl = get-acl "D:\My Documents"

$AccessRule = New-Object Security.AccessControl.FileSystemAccessRule("Users", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")

$AccessControl.AddAccessRule($AccessRule) set-acl -aclobject

$AccessControl -path "D:\My Documents"

Syndicate content