【发布时间】:2015-02-03 21:36:17
【问题描述】:
尝试使用 Powershell,我正在尝试弄清楚如何向我们的用户帐户添加特定权限。下面的代码会将服务帐户添加到文件夹Security 选项卡,但它不会调整权限。知道为什么吗?
#variables
$okeeffename = "WCFService"
$domain = "InsideServices.dev.com"
$okeeffedirectory = "d:\webcontent\$domain\$okeeffename"
#create webcontent and application folders
Write-Host "Creating directories" -ForegroundColor Yellow
New-Item -Path $okeeffedirectory -type directory -ErrorAction Stop
#adjust security for folders
$okeefferights = Get-Acl $okeeffedirectory
$read = New-Object system.security.accesscontrol.filesystemaccessrule($useraccount, "Read", "Allow")
$list = New-Object system.security.accesscontrol.filesystemaccessrule($useraccount, "ListDirectory", "Allow")
$readexecute = New-Object system.security.accesscontrol.filesystemaccessrule($useraccount, "ReadAndExecute", "Allow")
$okeefferights.SetAccessRule($read)
$okeefferights.SetAccessRule($list)
$okeefferights.SetAccessRule($readexecute)
Set-Acl -Path $okeeffedirectory -AclObject $okeefferights
第二个问题:我正在尝试将服务帐户的以下权限添加到文件夹中。有人可以指出 Powershell 用于List Folder Contents 权限的关键字吗?
编辑
通过切换FileSystemRights 的Allow/Deny 值,我发现每个规范都只更改文件夹的Special Permissions 权限。快速屏幕截图:
【问题讨论】:
标签: powershell iis windows-server-2012