LoginSignup
0
3

More than 5 years have passed since last update.

PowerShellでNTFSアクセス許可を設定する

Posted at

Script

ローカルユーザーlocalUserにE:/ShareフォルダのNTFSアクセス許可(編集)を与える.

$folder = E:¥Share
$hostname = [System.Environment]::MachineName
$user= "user"
$aclParams = @("$hostname\$user",
    [System.Security.AccessControl.FileSystemRights]::Modify,
    [System.Security.AccessControl.InheritanceFlags]::None,
    [System.Security.AccessControl.PropagationFlags]::None,
    [System.Security.AccessControl.AccessControlType]::Allow)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule  $aclParams
$acl = Get-Acl $folder
$acl.AddAccessRule($rule)
Set-Acl $folder -AclObject $acl

補足

NTFSって?

Windows NT系のファイルシステムらしい.

参考

http://yomon.hatenablog.com/entry/2015/04/10/170518
https://www.blackcat.xyz/article.php/ProgFAQ-PS_Set-Acl
http://tech.lecume.net/power-shell/configure-filesystem-acl

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3