You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Add-NTFSAccess.md 11 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. ---
  2. external help file: NTFSSecurity.dll-Help.xml
  3. Module Name: ntfssecurity
  4. online version:
  5. schema: 2.0.0
  6. ---
  7. # Add-NTFSAccess
  8. ## SYNOPSIS
  9. Adds an access control entry (ACE) to an object.
  10. ## SYNTAX
  11. ### PathComplex (Default)
  12. ```PowerShell
  13. Add-NTFSAccess [-Path] <String[]> [-Account] <IdentityReference2[]> [-AccessRights] <FileSystemRights2>
  14. [-AccessType <AccessControlType>] [-InheritanceFlags <InheritanceFlags>]
  15. [-PropagationFlags <PropagationFlags>] [-PassThru] [<CommonParameters>]
  16. ```
  17. ### PathSimple
  18. ```PowerShell
  19. Add-NTFSAccess [-Path] <String[]> [-Account] <IdentityReference2[]> [-AccessRights] <FileSystemRights2>
  20. [-AccessType <AccessControlType>] [-AppliesTo <ApplyTo>] [-PassThru] [<CommonParameters>]
  21. ```
  22. ### SDSimple
  23. ```PowerShell
  24. Add-NTFSAccess [-SecurityDescriptor] <FileSystemSecurity2[]> [-Account] <IdentityReference2[]>
  25. [-AccessRights] <FileSystemRights2> [-AccessType <AccessControlType>] [-AppliesTo <ApplyTo>] [-PassThru]
  26. [<CommonParameters>]
  27. ```
  28. ### SDComplex
  29. ```PowerShell
  30. Add-NTFSAccess [-SecurityDescriptor] <FileSystemSecurity2[]> [-Account] <IdentityReference2[]>
  31. [-AccessRights] <FileSystemRights2> [-AccessType <AccessControlType>] [-InheritanceFlags <InheritanceFlags>]
  32. [-PropagationFlags <PropagationFlags>] [-PassThru] [<CommonParameters>]
  33. ```
  34. ## DESCRIPTION
  35. Adds an access control entry (ACE) to an object such as a file or folder. NTFSSecurity allows you to apply basic permission groups (read, read/write, full) or advanced permissions that allow you to get granular with the permissions. See the below table for how the basic permissions map to the advanced permissions, and how NTFSSecurity handles them.
  36. | NTFSSecurity | AccessRight displayed | Advanced Security Window |
  37. |------------------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------|
  38. | ReadData | ListDirectory | List Folder / Read Data |
  39. | ListDirectory | ListDirectory | List Folder / Read Data |
  40. | WriteData | CreateFile | Create Files / Write Data |
  41. | CreateFiles | CreateFile | Create Files / Write Data |
  42. | AppendData | CreateDirectories | Create Folders / Append Data |
  43. | CreateDirectories | CreateDirectories | Create Folders / Append Data |
  44. | ReadExtendedAttributes | ReadExtendedAttributes | Read Extended Attributes |
  45. | WriteExtendedAttributes | WriteExtendedAttributes | WriteExtendedAttributes |
  46. | ExecuteFile | Traverse | Traverse Folder / Execute File |
  47. | Traverse | Traverse | Traverse Folder / Execute File |
  48. | DeleteSubdirectoriesAndFiles | DeleteSubdirectoriesAndFiles | Delete Sub-folders and Files |
  49. | ReadAttributes | ReadAttributes | Read Attributes |
  50. | WriteAttributes | WriteAttributes | Write Attributes |
  51. | Write | Write | Create Files / Write Data, Create Folders / Append Data, Write-Attributes, Write Extended Attributes |
  52. | Delete | Delete | Delete |
  53. | ReadPermissions | ReadPermissions | Read Permissions |
  54. | Read | Read | List Folder / Read Data, Read Attributes, Read Extended Attributes, Read Permissions |
  55. | ReadAndExecute | ReadAndExecute | Traverse Folder / Execute File, List Folder / Read Data, Read Attributes, Read Extended Attributes, Read Permissions |
  56. | Modify | Modify | Everything except Full Control, Delete SubFolders and Files, Change Permissions, Take Ownership |
  57. | ChangePermissions | ChangePermissions | Change Permissions |
  58. ## EXAMPLES
  59. ### Example 1
  60. ```PowerShell
  61. PS C:\> Add-NTFSAccess -Path C:\Data -Account 'NT AUTHORITY\Authenticated Users' -AccessRights Read
  62. ```
  63. The above command gives the read permissions to the built-in group of 'Authenticated users'.
  64. ### Example 2
  65. ```PowerShell
  66. PS C:\> Add-NTFSAccess -Path C:\Data -Account 'Contoso\Domain Admins' -AccessRights Full
  67. ```
  68. The above command gives full permissions to the domain administrators group in the contoso active directory.
  69. ### Example 3
  70. ```PowerShell
  71. PS C:\> Add-NTFSAccess -Path C:\Data -Account 'NT AUTHORITY\Authenticated Users' -AccessRights CreateFiles -AccessType Deny -AppliesTo ThisFolderOnly
  72. ```
  73. The above command denies the the built-in group of 'Authenticated users' from creating files in this folder only.
  74. ## PARAMETERS
  75. ### -AccessRights
  76. The AccessRights parameter designates the permissions to assign. There are individual permissions as well as 'basic' permissions. See the below table for how the basic permissions permissions map the the advanced permissions in the advanced security window.
  77. ```yaml
  78. Type: FileSystemRights2
  79. Parameter Sets: (All)
  80. Aliases: FileSystemRights
  81. Accepted values: None, ReadData, ListDirectory, WriteData, CreateFiles, AppendData, CreateDirectories, ReadExtendedAttributes, WriteExtendedAttributes, ExecuteFile, Traverse, DeleteSubdirectoriesAndFiles, ReadAttributes, WriteAttributes, Write, Delete, ReadPermissions, Read, ReadAndExecute, Modify, ChangePermissions, TakeOwnership, Synchronize, FullControl, GenericAll, GenericExecute, GenericWrite, GenericRead
  82. Required: True
  83. Position: 3
  84. Default value: None
  85. Accept pipeline input: True (ByPropertyName)
  86. Accept wildcard characters: False
  87. ```
  88. ### -AccessType
  89. The AccessType parameter determines if the ACE allows or denies the permissions assigned.
  90. ```yaml
  91. Type: AccessControlType
  92. Parameter Sets: (All)
  93. Aliases: AccessControlType
  94. Accepted values: Allow, Deny
  95. Required: False
  96. Position: Named
  97. Default value: None
  98. Accept pipeline input: True (ByPropertyName)
  99. Accept wildcard characters: False
  100. ```
  101. ### -Account
  102. The Account parameter defines the account or group to apply the permissions to.
  103. ```yaml
  104. Type: IdentityReference2[]
  105. Parameter Sets: (All)
  106. Aliases: IdentityReference, ID
  107. Required: True
  108. Position: 2
  109. Default value: None
  110. Accept pipeline input: True (ByPropertyName)
  111. Accept wildcard characters: False
  112. ```
  113. ### -AppliesTo
  114. The AppliesTo parameter defines where the permissions apply to and if there is any inheritance e.g this folder and subfolders.
  115. ```yaml
  116. Type: ApplyTo
  117. Parameter Sets: PathSimple, SDSimple
  118. Aliases:
  119. Accepted values: ThisFolderOnly, ThisFolderSubfoldersAndFiles, ThisFolderAndSubfolders, ThisFolderAndFiles, SubfoldersAndFilesOnly, SubfoldersOnly, FilesOnly, ThisFolderSubfoldersAndFilesOneLevel, ThisFolderAndSubfoldersOneLevel, ThisFolderAndFilesOneLevel, SubfoldersAndFilesOnlyOneLevel, SubfoldersOnlyOneLevel, FilesOnlyOneLevel
  120. Required: False
  121. Position: Named
  122. Default value: None
  123. Accept pipeline input: True (ByPropertyName)
  124. Accept wildcard characters: False
  125. ```
  126. ### -InheritanceFlags
  127. {{ Fill InheritanceFlags Description }}
  128. ```yaml
  129. Type: InheritanceFlags
  130. Parameter Sets: PathComplex, SDComplex
  131. Aliases:
  132. Accepted values: None, ContainerInherit, ObjectInherit
  133. Required: False
  134. Position: Named
  135. Default value: None
  136. Accept pipeline input: True (ByPropertyName)
  137. Accept wildcard characters: False
  138. ```
  139. ### -PassThru
  140. {{ Fill PassThru Description }}
  141. ```yaml
  142. Type: SwitchParameter
  143. Parameter Sets: (All)
  144. Aliases:
  145. Required: False
  146. Position: Named
  147. Default value: None
  148. Accept pipeline input: False
  149. Accept wildcard characters: False
  150. ```
  151. ### -Path
  152. The Path parameter defines where the file or container exists.
  153. ```yaml
  154. Type: String[]
  155. Parameter Sets: PathComplex, PathSimple
  156. Aliases: FullName
  157. Required: True
  158. Position: 1
  159. Default value: None
  160. Accept pipeline input: True (ByPropertyName, ByValue)
  161. Accept wildcard characters: False
  162. ```
  163. ### -PropagationFlags
  164. {{ Fill PropagationFlags Description }}
  165. ```yaml
  166. Type: PropagationFlags
  167. Parameter Sets: PathComplex, SDComplex
  168. Aliases:
  169. Accepted values: None, NoPropagateInherit, InheritOnly
  170. Required: False
  171. Position: Named
  172. Default value: None
  173. Accept pipeline input: True (ByPropertyName)
  174. Accept wildcard characters: False
  175. ```
  176. ### -SecurityDescriptor
  177. {{ Fill SecurityDescriptor Description }}
  178. ```yaml
  179. Type: FileSystemSecurity2[]
  180. Parameter Sets: SDSimple, SDComplex
  181. Aliases:
  182. Required: True
  183. Position: 1
  184. Default value: None
  185. Accept pipeline input: True (ByPropertyName, ByValue)
  186. Accept wildcard characters: False
  187. ```
  188. ### CommonParameters
  189. This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
  190. ## INPUTS
  191. ### System.String[]
  192. ### Security2.FileSystemSecurity2[]
  193. ### Security2.IdentityReference2[]
  194. ### Security2.FileSystemRights2
  195. ### System.Security.AccessControl.AccessControlType
  196. ### System.Security.AccessControl.InheritanceFlags
  197. ### System.Security.AccessControl.PropagationFlags
  198. ### Security2.ApplyTo
  199. ## OUTPUTS
  200. ### Security2.FileSystemAccessRule2
  201. ## NOTES
  202. ## RELATED LINKS