SoFunction
Updated on 2025-03-10

Inheritance and specifying methods for Powershell directory folder management permissions

Inheritance and specifying methods for Powershell directory folder management permissions

Updated: June 20, 2015 09:31:41 Submission: junjie
This article mainly introduces the inheritance and specification methods of Powershell directory folder management permissions. This article provides the creation of folders, obtaining current permissions, adding new permissions, adding administrator permissions, etc. If you need it, please refer to it.

The permissions of the default directory are inherited from the parent directory, and you can of course turn off its inheritance and assign specified permissions.
The following example creates a folder of "PermissionNoInheritance" that allows the current user to read, while the administrator group obtains all its administrative rights and closes its inheritance.

# create folder
$Path = 'c:\PermissionNoInheritance'
$null = New-Item -Path $Path -ItemType Directory -ErrorAction SilentlyContinue
 
# get current permissions
$acl = Get-Acl -Path $path
 
# add a new permission for current user
$permission = $env:username, 'Read,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName  -ArgumentList $permission
$($rule)
 
# add a new permission for Administrators
$permission = 'Administrators', 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName  -ArgumentList $permission
$($rule)
 
# disable inheritance
$($true, $false)
 
# set new permissions
$acl | Set-Acl -Path $path

  • Powershell
  • Table of contents
  • Folders
  • Permissions
  • inherit
  • Specify

Related Articles

  • Defining hash (Hash) and call examples in PowerShell

    This article mainly introduces the definition of hash hash (Hash) and call examples in PowerShell. This article introduces how to create a hash variable in PowerShell and use hash variables. Friends who need it can refer to it.
    2014-08-08
  • Introduction to common properties and methods of Get-Date objects in PowerShell

    This article mainly introduces the common properties and methods of Get-Date objects in PowerShell, and also introduces the skills to see all properties and methods of an object. Friends who need it can refer to it.
    2014-08-08
  • PowerShell Getting Started Tutorial for Accessing .Net Assembly, COM, and WMI Instances

    This article mainly introduces the access to the PowerShell introductory tutorial.Net assembly, COM and WMI examples. This article explains the example of PowerShell as the dehydrated language of the Windows platform to access other resources. Friends who need it can refer to it.
    2014-10-10
  • Windows Powershell extends aliases through functions

    This article mainly introduces Windows Powershell to extend the alias through functions. Friends who need it can refer to it.
    2014-09-09
  • Use Filter in PowerShell to create pipeline input functions

    This article mainly introduces the use of Filter in PowerShell to create pipeline input functions. The functions created by Filter are essentially the same as those created by Function. Friends who need it can refer to it.
    2014-07-07
  • PowerShell calls the Web Test Tool Selenium instance

    This article mainly introduces the Selenium instance of PowerShell calling the Web Test Tool, and another example of PowerShell operating web pages. Friends who need it can refer to it
    2014-07-07
  • Example of SSL certificate expiration monitoring of script implementation

    This article mainly introduces the script to implement SSL certificate expiration monitoring examples. Interested friends can try to implement it. I hope it will be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase.
    2022-03-03
  • Introduction to 4 types of execution permissions for Powershell scripts

    This article mainly introduces the four execution permissions of Powershell scripts. Windows does not allow any scripts to run by default. You can use the "Set-ExecutionPolicy" cmdlet to change your PowerShell environment. There are 4 types of execution permissions in total. Friends who need it can refer to it.
    2015-06-06
  • PowerShell 3.0 Manage Hyper-V 3.0

    This article mainly introduces the relevant information on PowerShell 3.0 management of Hyper-V 3.0. It is very detailed. Friends who need it can refer to it.
    2015-09-09
  • Example of a Powershell script containing file resources

    This article mainly introduces examples of the file resources included in Powershell scripts. This article directly gives sample code. The script code in this article is suitable for Powershell 3.0 and later versions. Friends who need it can refer to it.
    2015-03-03

Latest Comments