欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Powershell目錄文件夾管理權(quán)限的繼承和指定方法

 更新時(shí)間:2015年06月20日 09:31:41   投稿:junjie  
這篇文章主要介紹了Powershell目錄文件夾管理權(quán)限的繼承和指定方法,本文給出了創(chuàng)建文件夾、獲取當(dāng)前權(quán)限、添加新的權(quán)限、添加管理員權(quán)限等,需要的朋友可以參考下

默認(rèn)目錄的權(quán)限是繼承父目錄的,你當(dāng)然可以關(guān)閉它的繼承和分配指定的權(quán)限。
下面例子創(chuàng)建了“PermissionNoInheritance”的文件夾,允許當(dāng)前用戶(hù)讀取,同時(shí)管理員組獲得其所有管理權(quán)限,并關(guān)閉它的繼承。

# 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 System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permission
$acl.SetAccessRule($rule)
 
# add a new permission for Administrators
$permission = 'Administrators', 'FullControl', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permission
$acl.SetAccessRule($rule)
 
# disable inheritance
$acl.SetAccessRuleProtection($true, $false)
 
# set new permissions
$acl | Set-Acl -Path $path

相關(guān)文章

最新評(píng)論