[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[转载代码] [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:
  1. function New-Folder
  2. {
  3.   param
  4.   (
  5.     [String]
  6.     $path,
  7.     [String]
  8.     $username = "$env:userdomain\$env:username"
  9.   )
  10.   If ( (Test-Path -Path $path) -eq $false )
  11.   {
  12.     New-Item $path -Type Directory | Out-Null
  13.   }
  14.   icacls $path /inheritance:r /grant '*S-1-5-32-544:(OI)(CI)R' ('{0}:(OI)(CI)F' -f $username)
  15. }
复制代码
http://powershell.com/cs/blogs/tips/archive/2014/03/21/applying-ntfs-access-rules.aspx

返回列表