标题: [转载代码] [PowerShell每日技巧]调用icacls.exe设置NTFS权限(20140321) [打印本页]
作者: DAIC 时间: 2014-4-3 09:41 标题: [PowerShell每日技巧]调用icacls.exe设置NTFS权限(20140321)
There are many ways to add or change NTFS permissions. One is to reuse existing tools such as icacls.exe.
This function will create new folders that have default permissions. The script uses icacls.exe to explicitly add full permissions to the current user and read permisssions to local Administrators:- function New-Folder
- {
- param
- (
- [String]
- $path,
-
- [String]
- $username = "$env:userdomain\$env:username"
- )
-
- If ( (Test-Path -Path $path) -eq $false )
- {
- New-Item $path -Type Directory | Out-Null
- }
-
- icacls $path /inheritance:r /grant '*S-1-5-32-544:(OI)(CI)R' ('{0}:(OI)(CI)F' -f $username)
- }
复制代码
http://powershell.com/cs/blogs/tips/archive/2014/03/21/applying-ntfs-access-rules.aspx
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |