Inheritance and specifying methods for Powershell directory folder management permissions
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
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-08Introduction 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-08PowerShell 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-10Windows 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-09Use 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-07PowerShell 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 it2014-07-07Example 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-03Introduction 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-06PowerShell 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-09Example 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