Friday, May 27, 2016

Great Script for Managing NTFS Permissions

Hi folks,

I would love to share with you about one of my recent findings, namely PowerShell module for managing NTFS file and folder permissions. Its is available on the TechNet script gallery.You can download NTFSSecurity Module from this linkHere you can read about some basics about how to manage NTFS permissions. Actually there is one more arcticle and you can find its link at the download link.

After module is downloaded (in form of zip file) you will need to deploy it on your Windows server or client box (I played with the former thought, so I leave client to you).

To install NTFSSecurity Module on your Windows 2012 server you will need to unzip files and copy all of them to %Windir%\System32\WindowsPowerShell\v1.0\Modules. If you are as lazy as I am below is the code to do it automatically (of course you may have a different folder from where you are copying your module files:

New-Item "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\NTFSSecurity" -Type Directory
Copy-Item D:\\Scripts\NTFSSecurity\* "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\NTFSSecurity"

After which you can
Import-Module NTFSSecurity

Below are some Sample Commands that I played with:

View NTFS permission:
Get-Item C:\Folder |Get-NTFSAccess

Add Full Access to one of the well-known Windows SIDs:
New-Item G:\Folder -Type Directory
Add-NTFSAccess -Path C:\Folder -Account 'NT AUTHORITY\NETWORK SERVICE' -AccessRights FullControl -AppliesTo ThisFolderSubfoldersAndFiles

Add full access to a domain user named john.smith:
Add-NTFSAccess -Path C:\Folder -Account 'contoso\john.smith' -AccessRights FullControl -AppliesTo ThisFolderSubfoldersAndFiles

Isn't it cool? As I love saying PowerShell is indeed Power Shell!

Enjoy


No comments:

Post a Comment