mirror of https://github.com/raandree/NTFSSecurity
Browse Source
* chore: initialize the memory bank Add the canonical .memory-bank base with evidence-based project context: purpose and scope, workflows, stack and validation commands, architecture map, decisions, and the open work found while documenting the cmdlets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com> * docs: align documentation with the cmdlet source - Fill all 36 platyPS cmdlet pages from the C# source: synopsis, description, parameters, defaults, examples, inputs, outputs, and notes, including documented limitations of the current code - Check every example against live parameter metadata and run them in a sandbox; fix examples that did not work (CSV restore, account filter, recursive inheritance, -AccessRights typos) - Rewrite the home, concepts, examples, README, and contributor pages; add a grouped cmdlet overview, module settings, privileges, long paths, and the platyPS workflow - Document Remove-Item2 -PassThru as renamed after 4.2.6 (#64) - Fix mkdocs.yml navigation, edit_uri, and copyright markup; add build.os and a pinned MkDocs version for Read the Docs - Point online help links to the pages on GitHub; add CHANGELOG.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com> * ci: build the module and check the docs against the build The documentation check ran Update-MarkdownHelp against the NTFSSecurity release from the PowerShell Gallery (4.2.6), so it failed for every unreleased parameter change. PR #91 failed because 4.2.6 still has Remove-Item2 -PassThur while the source and the docs have -PassThru. - Build NTFSSecurity.csproj in Release on the Visual Studio 2022 image, using the .NET Framework 4.5.2 reference assemblies package instead of an installed targeting pack - Check Docs/Cmdlets against the module built from source - Pin platyPS 0.14.2 and MarkdownLinkCheck 0.2.0, and enable TLS 1.2 so the NuGet provider bootstrap works Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com> * chore: record the green PR 91 build in the memory bank Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com>pull/92/head
committed by
GitHub
57 changed files with 3719 additions and 795 deletions
@ -0,0 +1,30 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: active-agent |
|||
source: current task evidence |
|||
--- |
|||
|
|||
# Active context |
|||
|
|||
## Current focus |
|||
|
|||
PR #91 (`ai/docs-alignment`): CI fixed by building the module from source |
|||
in `appveyor.yml` and checking the docs against that build. |
|||
|
|||
## Evidence |
|||
|
|||
- AppVeyor build 54825990 failed in step 01: `Update-MarkdownHelp` against |
|||
the Gallery module 4.2.6 rewrote `Remove-Item2 -PassThru` to `-PassThur`. |
|||
- Against a Release build of the source, `Update-MarkdownHelp` changes none |
|||
of the 36 pages; a simulation of all `appveyor.yml` steps in a fresh clone |
|||
passed, and a page with stale syntax made it fail as intended. |
|||
- The link check (`Get-MarkdownLink -BrokenOnly`) finds 308 links, none |
|||
broken. |
|||
- Read the Docs project `ntfssecurity` still builds the fork |
|||
`Sup3rlativ3/NTFSSecurity`. |
|||
|
|||
## Next step |
|||
|
|||
PR #91 is green (AppVeyor 54828078 branch and 54828080 pull request, both |
|||
on `dbd8d16`). Await review and merge; open follow-ups are in `progress.md`. |
|||
@ -0,0 +1,46 @@ |
|||
--- |
|||
schema-version: 1 |
|||
loading-mode: routed |
|||
status: accepted |
|||
owner: shared |
|||
last-verified: 2026-10-02 |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# Memory Bank index |
|||
|
|||
Read this file first. It routes tasks to the smallest relevant set of Memory |
|||
Bank files. |
|||
|
|||
## Full-read fallback |
|||
|
|||
Set `loading-mode` to `full` to restore complete-base loading. Also fail open |
|||
when this index is missing or invalid, the task is ambiguous, routes conflict, |
|||
a listed file is missing, or a critical fact cannot be found. Full mode also |
|||
reads every existing `decisions/*.md` record. |
|||
|
|||
## Routing table |
|||
|
|||
Combine routes when a task spans topics. For durable repository writes, also |
|||
read `activeContext.md` before editing. |
|||
|
|||
| Route | Task signals | Read | |
|||
|---|---|---| |
|||
| `general` | General Q&A with no project decision | Index only | |
|||
| `continuation` | Resume, current focus, next step | `activeContext.md`, `progress.md` | |
|||
| `scope` | Purpose, scope, requirements, Acceptance criteria | `projectbrief.md` | |
|||
| `product` | Users, problem, workflow, experience goal | `productContext.md` | |
|||
| `implementation` | Code, configuration, build, test, dependency, deployment | `techContext.md`, `activeContext.md` | |
|||
| `architecture` | Design, pattern, decision, migration, integration | `systemPatterns.md`, relevant `decisions/*.md` | |
|||
| `status` | Progress, recent change, open work | `progress.md`, `activeContext.md` | |
|||
| `language` | Canonical terms in authored artifacts | `glossary.md` | |
|||
| `interaction-history` | Session analysis, prompt trends, Memory Bank evals | `promptHistory.md`, `progress.md` | |
|||
| `role` | Active Custom agent domain workflow | Only that agent's declared role files | |
|||
|
|||
## Authority order |
|||
|
|||
1. The user's current request controls task constraints. |
|||
2. Repository source, configuration, tests, and evidence control facts. |
|||
3. Accepted decision records control durable architectural choices. |
|||
4. Core Memory Bank files control only their assigned topic. |
|||
5. Historical logs never override current source. |
|||
@ -0,0 +1,42 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: shared |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# Product context |
|||
|
|||
## Problem |
|||
|
|||
PowerShell ships only `Get-Acl` and `Set-Acl`; everything between reading |
|||
and writing an ACL (permission reports, adding or removing one entry, |
|||
inheritance, ownership, orphaned SIDs) needs custom .NET code. The module |
|||
provides task-level cmdlets for these jobs (`README.md` summary). |
|||
|
|||
## Users |
|||
|
|||
- People who manage NTFS file and folder permissions with PowerShell |
|||
(README summary). Specific personas: To confirm. |
|||
|
|||
## Core workflows |
|||
|
|||
1. Report permissions: `Get-NTFSAccess`, `Get-NTFSSimpleAccess`, |
|||
`Get-NTFSEffectiveAccess`. |
|||
2. Change permissions: `Add-NTFSAccess`, `Remove-NTFSAccess`, |
|||
`Clear-NTFSAccess`; the audit equivalents manage the SACL. |
|||
3. Back up and restore explicit permissions through CSV |
|||
(`Get-NTFSAccess | Export-Csv`, `Import-Csv | Add-NTFSAccess`). |
|||
4. Find and remove orphaned entries: `Get-NTFSOrphanedAccess`. |
|||
5. Repair inheritance and ownership: `*-NTFSAccessInheritance`, |
|||
`Set-NTFSInheritance`, `Set-NTFSOwner`, using backup/restore privileges. |
|||
6. Work with paths longer than 260 characters: `Get-ChildItem2` and the other |
|||
`*-Item2` cmdlets. |
|||
|
|||
## Experience goals |
|||
|
|||
- Pipeline first: item cmdlets emit objects whose `FullName` binds to `-Path`. |
|||
- Accept account names and SIDs; output shows both when resolvable. |
|||
- Output formatted like `Get-ChildItem` (`NTFSSecurity.format.ps1xml`). |
|||
- Work on files the caller cannot normally open by enabling the Backup, |
|||
Restore, TakeOwnership, and Security privileges automatically. |
|||
@ -0,0 +1,53 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: active-agent |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# Progress |
|||
|
|||
## Current status |
|||
|
|||
Documentation matches the cmdlets at HEAD. The module source is unchanged |
|||
since the 4.2.6 release except the `Remove-Item2 -PassThru` rename and |
|||
`CompatiblePSEditions`. |
|||
|
|||
## Recent milestones |
|||
|
|||
- 2026-10-02: Memory Bank initialized. |
|||
- 2026-10-02: Documentation aligned with the code: 36 cmdlet pages filled |
|||
from the C# source and checked at runtime in a sandbox; Concepts, Examples, |
|||
home page, contributor guide, README rewritten; `mkdocs.yml` nav, |
|||
`edit_uri`, and `.readthedocs.yml` (`build.os`) fixed; `CHANGELOG.md` |
|||
created. |
|||
- 2026-10-02: PR #91 build fixed: `appveyor.yml` builds the module from |
|||
source and checks the docs against that build instead of the Gallery |
|||
release (root cause of the `Remove-Item2 -PassThru` drift failure). |
|||
|
|||
## Stable capabilities |
|||
|
|||
- 36 cmdlets: access (7), audit (5), inheritance (6), owner and security |
|||
descriptor (4), privileges (3), long-path items (6), links, hash, and |
|||
disk space (5). |
|||
- Works in Windows PowerShell 5.1 and PowerShell 7 (smoke-tested), except |
|||
`Get-FileHash2`, which fails in PowerShell 7 (missing `RIPEMD160` type). |
|||
|
|||
## Open work |
|||
|
|||
- Ship help: add the generated `en-US\NTFSSecurity.dll-Help.xml` to the |
|||
build and drop the stale `NTFSSecurity-Help.xml`. |
|||
- Publishing: re-point Read the Docs from the fork `Sup3rlativ3/NTFSSecurity` |
|||
to this repository (or create a new Read the Docs project). |
|||
- Manifest: remove `Show-NTFSSimpleAccess` and duplicates from |
|||
`CmdletsToExport`; bump `ModuleVersion` (4.2.5 in source, 4.2.6 released). |
|||
- Code defects found while documenting (each documented on its page): |
|||
`Add-NTFSAudit` duplicate position 2; SD parameter sets of |
|||
`Add/Remove-NTFSAccess/Audit` need `-AppliesTo`; `Set-NTFSInheritance` |
|||
nullable crash and hard-coded removal; inheritance cmdlets ignore |
|||
`EnablePrivileges = $false`; `Get-NTFSEffectiveAccess` |
|||
`-ExcludeNoneAccessEntries` and SD set ineffective; `-Account`/SD ignored by |
|||
`Get-NTFSOrphanedAccess/Audit` and `Get-NTFSSimpleAccess`; `Copy-Item2` |
|||
fails on folders with files; `Get-ChildItem2` throws on a file path; |
|||
`return` instead of `continue` in several `ProcessRecord` loops; wrong |
|||
`OutputType` on several cmdlets; `Get-FileHash2` in PowerShell 7. |
|||
@ -0,0 +1,42 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: shared |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# Project brief |
|||
|
|||
## Purpose |
|||
|
|||
NTFSSecurity is a binary (C#) PowerShell module that fills the gap between |
|||
`Get-Acl` and `Set-Acl`: cmdlets to read, add, remove, and clear NTFS |
|||
permissions (DACL) and audit rules (SACL), manage inheritance and ownership, |
|||
copy security descriptors, control process privileges, and work with long |
|||
paths (`*-Item2` cmdlets via AlphaFS), hard links, and symbolic links. |
|||
Source: `README.md`, `NTFSSecurity/NTFSSecurity.psd1`. |
|||
|
|||
## Scope |
|||
|
|||
- In scope: module source (`NTFSSecurity`, `Security2`, `PrivilegeControl`, |
|||
`ProcessPrivileges`), module manifest and type/format data, the MkDocs |
|||
documentation site in `Docs/`, and `README.md`. |
|||
- Out of scope: registry security. `Security2/Registry/RegistrySecurity.cs` |
|||
exists, but no registry cmdlet is exported. |
|||
- Distribution: PowerShell Gallery package `NTFSSecurity` and GitHub releases. |
|||
|
|||
## Stakeholders |
|||
|
|||
- Maintainer and author: Raimund Andree (`raandree`), per the manifest. |
|||
- Documentation contributors: James Smith (`mkdocs.yml` `site_author`); |
|||
the AppVeyor documentation build runs under the `Sup3rlativ3` account. |
|||
- End users: To confirm beyond the README summary. |
|||
|
|||
## Acceptance criteria |
|||
|
|||
1. Every exported cmdlet has an accurate platyPS page in `Docs/Cmdlets`. |
|||
2. `Update-MarkdownHelp` against the module produces no parameter drift |
|||
(the check in `appveyor.yml`). |
|||
3. The module imports in Windows PowerShell 5.1 and PowerShell 7 |
|||
(`CompatiblePSEditions = 'Core', 'Desktop'`). |
|||
4. Further release criteria: To confirm. |
|||
@ -0,0 +1,95 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: active-agent |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# System patterns |
|||
|
|||
## Architecture |
|||
|
|||
```text |
|||
NTFSSecurity.psd1 ─┬─ ScriptsToProcess: NTFSSecurity.Init.ps1 |
|||
│ Add-Type: Security2.dll, PrivilegeControl.dll, |
|||
│ ProcessPrivileges.dll, inline NTFS.DriveInfoExt; |
|||
│ Update-FormatData -PrependPath format.ps1xml |
|||
├─ TypesToProcess: NTFSSecurity.types.ps1xml |
|||
│ (Owner, IsInheritanceBlocked, LengthOnDisk on |
|||
│ FileInfo/DirectoryInfo; AccountType on ACEs) |
|||
├─ ModuleToProcess: NTFSSecurity.psm1 (aliases) |
|||
└─ NestedModules: NTFSSecurity.dll (36 cmdlets) |
|||
NTFSSecurity.dll ── cmdlets ──> Security2.dll (FileSystemAccessRule2, |
|||
FileSystemAuditRule2, IdentityReference2, |
|||
FileSystemInheritanceInfo, EffectiveAccess) |
|||
── long paths ──> AlphaFS |
|||
── privileges ──> PrivilegeControl / ProcessPrivileges |
|||
``` |
|||
|
|||
- `BaseCmdlet` resolves relative paths against `$PWD`. |
|||
- `BaseCmdletWithPrivControl` (access, audit, inheritance, owner, security |
|||
descriptor, and privilege cmdlets) enables Backup, Restore, TakeOwnership, |
|||
and Security in `BeginProcessing` when `PrivateData.EnablePrivileges` is |
|||
`$true`, and disables the ones it enabled in `EndProcessing`. |
|||
- `PrivateData` switches: `EnablePrivileges` (base cmdlet), |
|||
`GetInheritedFrom` (`Get-NTFSAccess`, `Get-NTFSAudit`), |
|||
`GetFileSystemModeProperty` and `IdentifyHardLinks` (`Get-ChildItem2`), |
|||
`ShowAccountSid` (format file). |
|||
- Cmdlets accept either `-Path` (alias `FullName`) or `-SecurityDescriptor` |
|||
(from `Get-NTFSSecurityDescriptor`); SD sets change the in-memory object |
|||
until `Set-NTFSSecurityDescriptor` writes it back. |
|||
|
|||
## Decisions |
|||
|
|||
### Decision 1: Use the canonical Memory Bank base |
|||
|
|||
- Choice: Keep durable project context in .memory-bank. |
|||
- Rationale: Preserve evidence-backed context across sessions. |
|||
|
|||
### Decision 2: Cmdlet reference stays platyPS markdown |
|||
|
|||
- Choice: `Docs/Cmdlets/*.md` keep the platyPS 0.14 schema 2.0.0 layout |
|||
(upper-case section headings, YAML parameter blocks, one paragraph per |
|||
line) so `Update-MarkdownHelp` and `New-ExternalHelp` round-trip. |
|||
- Rationale: `appveyor.yml` checks the pages with `Update-MarkdownHelp`; |
|||
the same files can generate MAML help. |
|||
|
|||
### Decision 3: Document the source at HEAD |
|||
|
|||
- Choice: Docs describe the code on `master`. Where HEAD differs from the |
|||
latest Gallery release, the page says which version changed. |
|||
- Rationale: The user asked to align docs with the actual code; the only |
|||
current difference is `Remove-Item2 -PassThru` (4.2.6 spells `-PassThur`). |
|||
|
|||
### Decision 4: Online help points to GitHub |
|||
|
|||
- Choice: `online version` of every cmdlet page is |
|||
`https://github.com/raandree/NTFSSecurity/blob/master/Docs/Cmdlets/<Name>.md`. |
|||
- Rationale: The Read the Docs project builds a stale fork, so its URLs show |
|||
outdated pages; GitHub always shows `master`. |
|||
|
|||
### Decision 5: Document defects, don't fix them in docs work |
|||
|
|||
- Choice: Code defects found while documenting are described on the affected |
|||
page (workaround or limitation) and listed in `progress.md`; source code is |
|||
changed only in separate, tested work. |
|||
- Rationale: No build toolchain was available to verify code changes, and |
|||
the docs must describe current behavior. |
|||
|
|||
### Decision 6: CI checks the docs against a build of the source |
|||
|
|||
- Choice: `appveyor.yml` builds `NTFSSecurity.csproj` and runs |
|||
`Update-MarkdownHelp` against `NTFSSecurity\bin\Release`, not against the |
|||
module from the PowerShell Gallery. |
|||
- Rationale: Checking against the last release fails for every unreleased |
|||
parameter change (PR #91 failed on `Remove-Item2 -PassThru`) and never |
|||
compiled the code. |
|||
|
|||
### Pattern: verifying documentation |
|||
|
|||
- Run platyPS in Windows PowerShell 5.1 against a module build; a copy of |
|||
`Docs/Cmdlets` must round-trip through `Update-MarkdownHelp` unchanged. |
|||
- platyPS rewrites non-ASCII punctuation such as em dashes; keep cmdlet pages |
|||
ASCII-only. |
|||
- Verify examples in a `$env:TEMP` sandbox, never on real data; parse every |
|||
example and check its parameters against `Get-Command` metadata. |
|||
@ -0,0 +1,71 @@ |
|||
--- |
|||
status: current |
|||
last-verified: 2026-10-02 |
|||
owner: active-agent |
|||
source: repository evidence |
|||
--- |
|||
|
|||
# Tech context |
|||
|
|||
## Stack |
|||
|
|||
- C# class libraries, old-style `.csproj`, .NET Framework 4.5.2, |
|||
solution `NTFSSecurity.sln` (Visual Studio 2017 format). |
|||
- Projects: `NTFSSecurity` (cmdlets), `Security2` (ACL object model, Win32 |
|||
interop), `PrivilegeControl` and `ProcessPrivileges` (token privileges), |
|||
`Log`, `TestClient`, `NTFSSecurityTest` (MSTest, minimal coverage). |
|||
- NuGet (`packages.config`): AlphaFS 2.2.x for long paths; |
|||
`System.Management.Automation.dll` 10.0.10586.0. |
|||
- Module: `NTFSSecurity.psd1` loads `NTFSSecurity.psm1` (aliases `dir2`, |
|||
`gi2`, `rm2`, `del2`), `NTFSSecurity.Init.ps1` (Add-Type of the helper |
|||
assemblies, prepends `NTFSSecurity.format.ps1xml`), and `NTFSSecurity.dll`. |
|||
- Documentation: MkDocs (`mkdocs.yml`, theme `readthedocs`, `docs_dir: ./Docs`) |
|||
built by Read the Docs (`.readthedocs.yml` v2); cmdlet pages are platyPS |
|||
0.14 markdown (schema 2.0.0) in `Docs/Cmdlets`. |
|||
|
|||
## Environment |
|||
|
|||
- Windows only (NTFS, Win32 security APIs). |
|||
- The Debug build writes straight into |
|||
`C:\Program Files\WindowsPowerShell\Modules\NTFSSecurity\`. |
|||
- No Visual Studio MSBuild or .NET Framework targeting pack on the |
|||
workstation. A local build works with the .NET Framework MSBuild |
|||
(`%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe`) plus |
|||
`/p:CscToolPath` to the Roslyn `csc.exe` of the `Microsoft.Net.Compilers` |
|||
package; the legacy C# 5 compiler fails with CS0136. `dotnet msbuild` |
|||
fails on the binary resources in `Resources.resx` (MSB3822, MSB3823). |
|||
|
|||
## Constraints |
|||
|
|||
- `ModuleVersion` in the source manifest is `4.2.5`; the latest tag and |
|||
Gallery release is `4.2.6`. |
|||
- HEAD differs from tag `4.2.6` only by the `Remove-Item2 -PassThur` to |
|||
`-PassThru` rename and `CompatiblePSEditions` in the manifest. |
|||
- `CmdletsToExport` lists `Show-NTFSSimpleAccess`, which no longer exists |
|||
(WinForms code removed in `d3063de`), and repeats the inheritance cmdlets. |
|||
- `NTFSSecurity/NTFSSecurity-Help.xml` is a stale pre-4.x MAML file for old |
|||
command names; binary-module help must be named `NTFSSecurity.dll-Help.xml`. |
|||
- CI: AppVeyor project `raandree/ntfssecurity` builds branches and pull |
|||
requests. Read the Docs (`ntfssecurity`) and a second AppVeyor project are |
|||
attached to the fork `Sup3rlativ3/NTFSSecurity`. |
|||
- `Get-FileHash2` fails in PowerShell 7; all other cmdlets passed a smoke |
|||
test in PowerShell 7.6. |
|||
|
|||
## Validation |
|||
|
|||
- CI (`appveyor.yml`, image Visual Studio 2022): restore `packages.config` |
|||
per project plus `Microsoft.NETFramework.ReferenceAssemblies.net452` |
|||
1.0.3, build `NTFSSecurity.csproj` in Release with |
|||
`TargetFrameworkRootPath`/`FrameworkPathOverride`, import |
|||
`NTFSSecurity\bin\Release\NTFSSecurity.psd1`, run `Update-MarkdownHelp`, |
|||
and fail on `git diff -- Docs/Cmdlets`; then `Get-MarkdownLink -BrokenOnly`. |
|||
- Run platyPS in Windows PowerShell 5.1 to avoid PowerShell 7.4+ |
|||
`-ProgressAction` noise. |
|||
- Placeholder check: no `{{` left in `Docs/Cmdlets/*.md`. |
|||
- Help build check: `New-ExternalHelp -Path ./Docs/Cmdlets` to a temp folder. |
|||
- Markdown lint: `npx markdownlint-cli2` with `MD013` limited to prose |
|||
(tables, code, and headings excluded) on the conceptual pages. |
|||
- YAML: `ConvertFrom-Yaml` (powershell-yaml) on `mkdocs.yml`, |
|||
`.readthedocs.yml`, and `appveyor.yml`; every `nav` target must exist. |
|||
- MkDocs needs Python, which this workstation does not have; `mkdocs build |
|||
--strict` was not run. |
|||
@ -0,0 +1,31 @@ |
|||
# Changelog |
|||
|
|||
All notable changes to this project are documented in this file. |
|||
|
|||
The format is based on |
|||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Releases up to |
|||
4.2.6 are described in the |
|||
[version history](https://github.com/raandree/NTFSSecurity/wiki/Version-History) |
|||
in the wiki. |
|||
|
|||
## [Unreleased] |
|||
|
|||
### Changed |
|||
|
|||
- **Breaking:** rename the `-PassThur` parameter of `Remove-Item2` to |
|||
`-PassThru` ([#64](https://github.com/raandree/NTFSSecurity/pull/64)) |
|||
- Declare support for Windows PowerShell and PowerShell 7 in the module |
|||
manifest ([#61](https://github.com/raandree/NTFSSecurity/issues/61)) |
|||
- Document every cmdlet with synopsis, description, parameters, examples, |
|||
inputs, outputs, and notes, checked against the source code |
|||
- Rewrite the home, concepts, examples, and contributor pages to match the |
|||
current cmdlets, including module settings, privileges, and long paths |
|||
|
|||
### Fixed |
|||
|
|||
- Fix documentation examples that did not work, such as restoring |
|||
permissions from a CSV file and filtering entries by account |
|||
- Fix the documentation site navigation, the "Edit on GitHub" links, and the |
|||
Read the Docs build configuration |
|||
|
|||
[Unreleased]: https://github.com/raandree/NTFSSecurity/compare/4.2.6...HEAD |
|||
@ -1,98 +1,268 @@ |
|||
# CORE CONCEPTS |
|||
|
|||
## Overview |
|||
|
|||
Before starting with the NTFSSecurity module there are some core concepts that you will need to understand. |
|||
|
|||
There are two ways you can handle permissions, basic and advanced. The basic set of permissions are goups of advanced permissions that allow you to assign common role such as 'Read', 'Read/Write', or 'Full'. Advanced permissions allow you granular control of what can and can't be access or used. The advanced permissions are commonly used to build custom Role-Based Access Control tooling. |
|||
|
|||
Below is an explaination taken from the fantastic site NTFS.com for each of the advanced file permissions. |
|||
|
|||
### Traverse Folder/Execute File |
|||
|
|||
* **Traverse Folder**: Allows or denies moving through a restricted folder to reach files and folders beneath the restricted folder in the folder hierarchy. Traverse folder takes effect only when the group or user is not granted the "Bypass traverse checking user" right in the Group Policy snap-in. This permission does not automatically allow running program files. |
|||
|
|||
* **Execute File**: Allows or denies running program (executable) files. |
|||
|
|||
### List Folder/Read Data |
|||
|
|||
* **List Folder**: Allows or denies viewing file names and subfolder names within the folder. List Folder only affects the contents of that folder and does not affect whether the folder you are setting the permission on will be listed. |
|||
|
|||
* **Read Data**: Allows or denies viewing data in files. |
|||
|
|||
### Read Attributes |
|||
|
|||
* Allows or denies viewing the attributes of a file or folder, for example, "read-only" and "hidden". |
|||
|
|||
### Read Extended Attributes |
|||
|
|||
* Allows or denies viewing the extended attributes of a file or folder. Extended attributes are defined by programs and may vary by program. |
|||
|
|||
### Create Files/Write Data |
|||
|
|||
* **Create Files**: Allows or denies creating files within the folder. |
|||
|
|||
* **Write Data**: Allows or denies making changes to a file and overwriting existing content. |
|||
|
|||
### Create Folders/Append Data |
|||
|
|||
* **Create Folders**: Allows or denies creating subfolders within the folder. |
|||
|
|||
* **Append Data**: Allows or denies making changes to the end of the file but not changing, deleting, or overwriting existing data. |
|||
|
|||
### Write Attributes |
|||
|
|||
* Allows or denies changing the attributes of a file or folder, for example, "read-only" or "hidden". |
|||
|
|||
* The Write Attributes permission does not imply creating or deleting files or folders, it only includes the permission to make changes to the attributes of an existing file or folder. |
|||
|
|||
### Write Extended Attributes |
|||
|
|||
* Allows or denies changing the extended attributes of a file or folder. Extended attributes are defined by programs and may vary by program. |
|||
|
|||
* The Write Extended Attributes permission does not imply creating or deleting files or folders, it only includes the permission to make changes to the extended attributes of an existing file or folder. |
|||
|
|||
### Delete Subfolders and Files |
|||
|
|||
* Allows or denies deleting subfolders and files, even if the Delete permission has not been granted on the subfolder or file. |
|||
|
|||
### Delete |
|||
|
|||
* Allows or denies deleting the file or folder. If you don't have Delete permission on a file or folder, you can still delete it if you have been granted Delete Subfolders and Files on the parent folder. |
|||
|
|||
### Read Permissions |
|||
|
|||
* Allows or denies reading permissions of a file or folder. |
|||
|
|||
### Change Permissions |
|||
|
|||
* Allows or denies changing permissions of the file or folder. |
|||
|
|||
### Take Ownership |
|||
|
|||
* Allows or denies taking ownership of the file or folder. The owner of a file or folder can always change permissions on it, regardless of any existing permissions that protect the file or folder. |
|||
|
|||
You can see how the basic permissions, advanced permissions, and the NTFSSecurity module relate to one another in the below table. |
|||
|
|||
| NTFSSecurity | AccessRight displayed | Advanced Security Window | |
|||
|------------------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------| |
|||
| ReadData | ListDirectory | List Folder / Read Data | |
|||
| ListDirectory | ListDirectory | List Folder / Read Data | |
|||
| WriteData | CreateFile | Create Files / Write Data | |
|||
| CreateFiles | CreateFile | Create Files / Write Data | |
|||
| AppendData | CreateDirectories | Create Folders / Append Data | |
|||
| CreateDirectories | CreateDirectories | Create Folders / Append Data | |
|||
| ReadExtendedAttributes | ReadExtendedAttributes | Read Extended Attributes | |
|||
| WriteExtendedAttributes | WriteExtendedAttributes | WriteExtendedAttributes | |
|||
| ExecuteFile | Traverse | Traverse Folder / Execute File | |
|||
| Traverse | Traverse | Traverse Folder / Execute File | |
|||
| DeleteSubdirectoriesAndFiles | DeleteSubdirectoriesAndFiles | Delete Sub-folders and Files | |
|||
| ReadAttributes | ReadAttributes | Read Attributes | |
|||
| WriteAttributes | WriteAttributes | Write Attributes | |
|||
| Write | Write | Create Files / Write Data, Create Folders / Append Data, Write-Attributes, Write Extended Attributes | |
|||
| Delete | Delete | Delete | |
|||
| ReadPermissions | ReadPermissions | Read Permissions | |
|||
| Read | Read | List Folder / Read Data, Read Attributes, Read Extended Attributes, Read Permissions | |
|||
| ReadAndExecute | ReadAndExecute | Traverse Folder / Execute File, List Folder / Read Data, Read Attributes, Read Extended Attributes, Read Permissions | |
|||
| Modify | Modify | Everything except Full Control, Delete SubFolders and Files, Change Permissions, Take Ownership | |
|||
| ChangePermissions | ChangePermissions | Change Permissions | |
|||
# Concepts |
|||
|
|||
This page explains the Windows security concepts that the NTFSSecurity |
|||
cmdlets work with: security descriptors, accounts, access rights, |
|||
inheritance, privileges, long paths, and the module settings. Read it before |
|||
you change permissions on production data. |
|||
|
|||
## Security descriptors |
|||
|
|||
Every file and folder on an NTFS volume has a security descriptor. The module |
|||
manages three of its parts: |
|||
|
|||
| Part | Purpose | Cmdlets | |
|||
| --- | --- | --- | |
|||
| Owner | The account that owns the item. The owner can always read and change the item's permissions. | `Get-NTFSOwner`, `Set-NTFSOwner` | |
|||
| Discretionary access control list (DACL) | Access control entries (ACEs) that allow or deny access. | `Get-NTFSAccess`, `Add-NTFSAccess`, `Remove-NTFSAccess`, `Clear-NTFSAccess` | |
|||
| System access control list (SACL) | Audit entries that tell Windows which access attempts to write to the Security event log. | `Get-NTFSAudit`, `Add-NTFSAudit`, `Remove-NTFSAudit`, `Clear-NTFSAudit` | |
|||
|
|||
Each entry is either explicit, which means it is set on the item itself, or |
|||
inherited from a parent folder. Inheritance is controlled separately for the |
|||
DACL and the SACL; see [Inheritance](#inheritance). |
|||
|
|||
Most cmdlets accept either `-Path` or `-SecurityDescriptor`: |
|||
|
|||
- With `-Path`, the cmdlet reads or writes the item directly. `-Path` |
|||
accepts pipeline input, so you can pipe the output of `Get-ChildItem`, |
|||
`Get-ChildItem2`, or `Get-Item2` into the cmdlet. |
|||
- With `-SecurityDescriptor`, the cmdlet changes a security descriptor object |
|||
that you got from `Get-NTFSSecurityDescriptor`. Nothing is written to disk |
|||
until you pass the object to `Set-NTFSSecurityDescriptor`, so you can make |
|||
several changes and write them in one step. |
|||
|
|||
When you pass a security descriptor to `Add-NTFSAccess`, `Remove-NTFSAccess`, |
|||
`Add-NTFSAudit`, or `Remove-NTFSAudit`, also specify `-AppliesTo` or the |
|||
`-InheritanceFlags` and `-PropagationFlags` parameters. Without them, |
|||
PowerShell cannot choose between the two security descriptor parameter sets |
|||
and reports that the parameter set cannot be resolved. |
|||
|
|||
## Accounts |
|||
|
|||
The `-Account` parameter accepts an account name, such as |
|||
`CONTOSO\JohnDoe`, `BUILTIN\Users`, or `NT AUTHORITY\SYSTEM`, or a security |
|||
identifier (SID) string, such as `S-1-5-32-545`. The output shows the account |
|||
name when Windows can resolve the SID. |
|||
|
|||
An entry whose SID no longer resolves to an account is called orphaned. |
|||
This happens when an account was deleted. `Get-NTFSOrphanedAccess` and |
|||
`Get-NTFSOrphanedAudit` list such entries. A SID can also fail to resolve |
|||
temporarily, for example when a domain controller is unreachable, so check |
|||
the results before you remove them. |
|||
|
|||
## Access rights |
|||
|
|||
The `-AccessRights` parameter takes a `FileSystemRights2` value. You can |
|||
combine values by passing a list, for example |
|||
`-AccessRights Delete, DeleteSubdirectoriesAndFiles`. |
|||
|
|||
PowerShell also accepts any unambiguous prefix of a value name, so `Full` |
|||
binds to `FullControl` and `Mod` binds to `Modify`. Use the full names in |
|||
scripts. |
|||
|
|||
### Basic permissions |
|||
|
|||
The basic permissions on the **Security** tab of the file or folder |
|||
properties are combinations of the advanced permissions: |
|||
|
|||
| `-AccessRights` value | Includes | Basic permission | |
|||
| --- | --- | --- | |
|||
| `Read` | `ListDirectory`, `ReadAttributes`, `ReadExtendedAttributes`, `ReadPermissions` | Read | |
|||
| `ReadAndExecute` | `Read` and `Traverse` | Read & execute | |
|||
| `Write` | `CreateFiles`, `CreateDirectories`, `WriteAttributes`, `WriteExtendedAttributes` | Write | |
|||
| `Modify` | `ReadAndExecute`, `Write`, and `Delete` | Modify | |
|||
| `FullControl` | `Modify`, `DeleteSubdirectoriesAndFiles`, `ChangePermissions`, `TakeOwnership`, and `Synchronize` | Full control | |
|||
|
|||
### Advanced permissions |
|||
|
|||
Several advanced permissions have two names because the same bit means |
|||
something different for files and for folders. The output always shows the |
|||
first name in the table. |
|||
|
|||
| `-AccessRights` value | Shown as | Advanced permission | Effect | |
|||
| --- | --- | --- | --- | |
|||
| `ListDirectory`, `ReadData` | `ListDirectory` | List folder / read data | List the contents of a folder; read the data of a file. | |
|||
| `CreateFiles`, `WriteData` | `CreateFiles` | Create files / write data | Create files in a folder; change or overwrite the data of a file. | |
|||
| `CreateDirectories`, `AppendData` | `CreateDirectories` | Create folders / append data | Create subfolders; append data to the end of a file. | |
|||
| `Traverse`, `ExecuteFile` | `Traverse` | Traverse folder / execute file | Move through a folder to reach items below it; run a program file. | |
|||
| `ReadAttributes` | `ReadAttributes` | Read attributes | Read attributes such as read-only and hidden. | |
|||
| `WriteAttributes` | `WriteAttributes` | Write attributes | Change attributes such as read-only and hidden. | |
|||
| `ReadExtendedAttributes` | `ReadExtendedAttributes` | Read extended attributes | Read the extended attributes that programs define. | |
|||
| `WriteExtendedAttributes` | `WriteExtendedAttributes` | Write extended attributes | Change the extended attributes that programs define. | |
|||
| `DeleteSubdirectoriesAndFiles` | `DeleteSubdirectoriesAndFiles` | Delete subfolders and files | Delete items in a folder, even without `Delete` on those items. | |
|||
| `Delete` | `Delete` | Delete | Delete the item. | |
|||
| `ReadPermissions` | `ReadPermissions` | Read permissions | Read the owner and the permissions. | |
|||
| `ChangePermissions` | `ChangePermissions` | Change permissions | Change the permissions. | |
|||
| `TakeOwnership` | `TakeOwnership` | Take ownership | Make yourself the owner. | |
|||
| `Synchronize` | `Synchronize` | Not shown | Wait on a file handle. | |
|||
|
|||
Windows adds `Synchronize` to every allow entry except `FullControl`, which |
|||
already contains it. Reading an entry back therefore shows, for example, |
|||
`Modify, Synchronize`. |
|||
|
|||
Windows also merges entries that have the same account, type, and |
|||
inheritance settings. Adding `Read` and then `Write` for the same account |
|||
results in one entry with both rights. |
|||
|
|||
The generic rights `GenericRead`, `GenericWrite`, `GenericExecute`, and |
|||
`GenericAll` are mapped by Windows to the file rights above. On a folder that |
|||
passes the entry on to its children, Windows stores two entries: one with the |
|||
mapped rights for the folder and one that keeps the generic right for the |
|||
child items. |
|||
|
|||
`Get-NTFSSimpleAccess` works on folders only. It condenses the rights of each |
|||
entry into the simple values `Read`, `Write`, and `Delete`. For every folder |
|||
after the first one, it reports only the entries that differ from the parent |
|||
folder, which shows where the permissions change in a folder tree. |
|||
|
|||
## Inheritance |
|||
|
|||
A folder passes its inheritable entries on to its child items. You can stop |
|||
an item from inheriting entries, separately for access entries and for audit |
|||
entries: |
|||
|
|||
- `Disable-NTFSAccessInheritance` blocks inheritance. By default, it copies |
|||
the inherited entries as explicit entries; `-RemoveInheritedAccessRules` |
|||
drops them instead. |
|||
- `Enable-NTFSAccessInheritance` restores inheritance and keeps the explicit |
|||
entries unless you use `-RemoveExplicitAccessRules`. |
|||
- `Get-NTFSInheritance` and `Set-NTFSInheritance` read and set both |
|||
settings at once. Unlike the dedicated cmdlets, `Set-NTFSInheritance` |
|||
removes the inherited access entries when it turns access inheritance off, |
|||
and removes the explicit audit entries when it turns audit inheritance on. |
|||
The audit equivalents of the dedicated cmdlets are |
|||
`Disable-NTFSAuditInheritance` and `Enable-NTFSAuditInheritance`. |
|||
|
|||
### The AppliesTo parameter |
|||
|
|||
Whether and how an entry is passed on is defined by its inheritance flags |
|||
and propagation flags. The `-AppliesTo` parameter of `Add-NTFSAccess`, |
|||
`Remove-NTFSAccess`, `Add-NTFSAudit`, and `Remove-NTFSAudit` sets both with |
|||
the names that the **Applies to** list in the **Advanced Security Settings** |
|||
dialog uses: |
|||
|
|||
| `-AppliesTo` value | `InheritanceFlags` | `PropagationFlags` | Applies to | |
|||
| --- | --- | --- | --- | |
|||
| `ThisFolderOnly` | `None` | `None` | This folder only | |
|||
| `ThisFolderSubfoldersAndFiles` | `ContainerInherit, ObjectInherit` | `None` | This folder, subfolders and files | |
|||
| `ThisFolderAndSubfolders` | `ContainerInherit` | `None` | This folder and subfolders | |
|||
| `ThisFolderAndFiles` | `ObjectInherit` | `None` | This folder and files | |
|||
| `SubfoldersAndFilesOnly` | `ContainerInherit, ObjectInherit` | `InheritOnly` | Subfolders and files only | |
|||
| `SubfoldersOnly` | `ContainerInherit` | `InheritOnly` | Subfolders only | |
|||
| `FilesOnly` | `ObjectInherit` | `InheritOnly` | Files only | |
|||
|
|||
Each value also exists with the suffix `OneLevel`, for example |
|||
`ThisFolderAndSubfoldersOneLevel`. These values add the `NoPropagateInherit` |
|||
propagation flag, which passes the entry on to the direct children only. In |
|||
the dialog, this is the check box **Only apply these permissions to objects |
|||
and/or containers within this container**. |
|||
|
|||
The flags mean: |
|||
|
|||
- `ContainerInherit`: child folders inherit the entry. |
|||
- `ObjectInherit`: child files inherit the entry. |
|||
- `InheritOnly`: the entry applies only to the children, not to the item |
|||
that holds it. |
|||
- `NoPropagateInherit`: the entry is passed on one level only. |
|||
|
|||
`Add-NTFSAccess` and `Add-NTFSAudit` use `ThisFolderSubfoldersAndFiles` by |
|||
default. Files have no children, so entries on files are stored without |
|||
inheritance flags. |
|||
|
|||
## Privileges |
|||
|
|||
Windows grants the following privileges to the local Administrators group. |
|||
They bypass the permission checks that would otherwise stop you from reading |
|||
or changing an item: |
|||
|
|||
| Privilege | Windows name | What it allows | |
|||
| --- | --- | --- | |
|||
| Backup | `SeBackupPrivilege` | Read any file or folder, regardless of its permissions. | |
|||
| Restore | `SeRestorePrivilege` | Write any file or folder and set any account as the owner. | |
|||
| Take ownership | `SeTakeOwnershipPrivilege` | Make yourself the owner of any item. | |
|||
| Security | `SeSecurityPrivilege` | Read and change audit entries (the SACL). | |
|||
|
|||
A privilege can only be enabled if the account holds it and the PowerShell |
|||
session runs elevated (**Run as administrator**). |
|||
|
|||
The access, audit, inheritance, owner, and security descriptor cmdlets enable |
|||
these privileges automatically while they run and disable the ones they |
|||
enabled when they finish. If a privilege cannot be enabled, the cmdlet |
|||
continues without it. You can turn this behavior off with the |
|||
`EnablePrivileges` module setting. The inheritance cmdlets are an exception: |
|||
they always try to enable the privileges, and when `EnablePrivileges` is |
|||
`$false`, they leave them enabled. |
|||
|
|||
`Enable-Privileges` enables the four privileges for the current PowerShell |
|||
process until you run `Disable-Privileges` or close the session. |
|||
`Get-Privileges` lists the privileges of the current process and their |
|||
state. |
|||
|
|||
When reading or changing an item fails with an access-denied error, most of |
|||
these cmdlets make the current user the owner of the item, retry, and then |
|||
restore the previous owner. This requires the privileges above. |
|||
|
|||
Reading or changing audit entries always requires the Security privilege. |
|||
Without it, the audit cmdlets fail, and `Get-NTFSEffectiveAccess` warns that |
|||
it might not be able to read the effective permissions. |
|||
|
|||
## Long paths |
|||
|
|||
Windows PowerShell 5.1 cannot handle paths longer than 260 characters; |
|||
`Get-ChildItem` fails on them. The cmdlets `Get-ChildItem2`, `Get-Item2`, |
|||
`Copy-Item2`, `Move-Item2`, `Remove-Item2`, and `Test-Path2` use the |
|||
[AlphaFS](https://github.com/alphaleonis/AlphaFS) library and work with long |
|||
paths. Their output binds to the `-Path` parameter of the NTFSSecurity |
|||
cmdlets, which handle long paths as well: |
|||
|
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSAccess -ExcludeInherited |
|||
``` |
|||
|
|||
The module defines the aliases `dir2` for `Get-ChildItem2`, `gi2` for |
|||
`Get-Item2`, and `rm2` and `del2` for `Remove-Item2`. |
|||
|
|||
## Extended file and folder objects |
|||
|
|||
The module extends the `FileInfo` and `DirectoryInfo` objects that |
|||
`Get-Item` and `Get-ChildItem` return. These members are not available on |
|||
the AlphaFS objects that the `*-Item2` cmdlets return. |
|||
|
|||
| Member | Type | Available on | Description | |
|||
| --- | --- | --- | --- | |
|||
| `Owner` | Property | Files and folders | The owner of the item. | |
|||
| `IsInheritanceBlocked` | Property | Files and folders | `$true` if the item does not inherit access entries. | |
|||
| `LengthOnDisk` | Property | Files | The file size rounded up to whole clusters of the volume. `Size` is an alias. | |
|||
| `EnableInheritance()` | Method | Files and folders | Turns on access inheritance. | |
|||
| `DisableInheritance()` | Method | Files and folders | Turns off access inheritance. Pass `$false` to drop the inherited entries instead of copying them. | |
|||
| `GetHash()` | Method | Files | Returns the SHA1 hash of the file as a hexadecimal string. | |
|||
|
|||
Access entries returned by `Get-NTFSAccess` have an additional `AccountType` |
|||
property. When the current user is a domain account, reading the property |
|||
queries Active Directory and returns the object class of the account, such |
|||
as `user` or `group`; otherwise, the property is empty. |
|||
|
|||
## Module settings |
|||
|
|||
The `PrivateData` section of `NTFSSecurity.psd1` contains switches that |
|||
change the module's behavior: |
|||
|
|||
| Setting | Default | Effect | |
|||
| --- | --- | --- | |
|||
| `EnablePrivileges` | `$true` | The security cmdlets enable the Backup, Restore, Take Ownership, and Security privileges while they run. | |
|||
| `GetInheritedFrom` | `$true` | `Get-NTFSAccess` and `Get-NTFSAudit` fill the `InheritedFrom` property with the path of the folder that an inherited entry comes from. | |
|||
| `GetFileSystemModeProperty` | `$true` | `Get-ChildItem2` adds the `Mode` property to its output. | |
|||
| `IdentifyHardLinks` | `$true` | `Get-ChildItem2` adds a `HardLinkCount` property to each file. | |
|||
| `ShowAccountSid` | `$false` | The default table output of access and audit entries shows the SID next to the account name. | |
|||
|
|||
`GetInheritedFrom`, `GetFileSystemModeProperty`, and `IdentifyHardLinks` |
|||
cost extra work for every item. Turn them off to speed up large folder |
|||
trees when you don't need the information. |
|||
|
|||
To change a setting for the current session only, change the value after |
|||
you import the module: |
|||
|
|||
```powershell |
|||
(Get-Module -Name NTFSSecurity).PrivateData.ShowAccountSid = $true |
|||
``` |
|||
|
|||
To change the default, edit `NTFSSecurity.psd1` in the module folder. |
|||
|
|||
@ -1,10 +1,14 @@ |
|||
# Contributor Guide |
|||
# Contributor guide |
|||
|
|||
Thank you for your interest in contributing to quality documentations. |
|||
As an open source project, we welcome input and updates from the community. |
|||
The following topics explain how to contribute to the NTFSAccess documentation. |
|||
Thank you for your interest in improving NTFSSecurity and its documentation. |
|||
As an open source project, NTFSSecurity welcomes input and updates from the |
|||
community. The following pages explain how to contribute to the |
|||
documentation: |
|||
|
|||
1. [Get started](./Contributing/01-Getting-Started.md) |
|||
2. [Writing PowerShell documentation](./Contributing/02-Writing.md) |
|||
1. [Get started](Contributing/01-Getting-Started.md) |
|||
2. [Write documentation](Contributing/02-Writing.md) |
|||
3. [Style guide](Contributing/03-Style-Guide.md) |
|||
4. [Markdown and platyPS specifics](Contributing/04-Markdown-Specifics.md) |
|||
|
|||
This contributor guide is a modified version of the one found on the [Powershell Docs](https://github.com/PowerShell/PowerShell-Docs) GitHub page. |
|||
This guide is adapted from the contributor guide of the |
|||
[PowerShell documentation](https://github.com/MicrosoftDocs/PowerShell-Docs). |
|||
|
|||
@ -1,54 +1,46 @@ |
|||
# Contributing to PowerShell Documentation |
|||
# Get started |
|||
|
|||
Thank you for your interest in NTFSAccess documentation! |
|||
This page explains how to report a problem with the NTFSSecurity |
|||
documentation and how to propose a change. For general information about Git |
|||
and GitHub, see the [GitHub documentation][git-help]. |
|||
|
|||
See below for details on how you can contribute to our technical documentation. |
|||
## Report a problem |
|||
|
|||
> For general information about getting started with Git and GitHub, see [GitHub Help][git-help]. |
|||
Report errors, suggest changes, or request new topics by |
|||
[creating an issue][new-issue] in the |
|||
[NTFSSecurity repository][issues]. Issues about the documentation use the |
|||
**Documentation** label. |
|||
|
|||
## Providing feedback on NTFSAccess documentation |
|||
## Make a small change |
|||
|
|||
Report errors, suggest changes, or request new topics by [creating an issue][new-issue] on the |
|||
[NTFSAccess repository issues page][doc-issues]. |
|||
To fix a typo or a sentence, open the page in the |
|||
[NTFSSecurity repository][repo] and select **Edit this file**. GitHub |
|||
creates a fork of the repository in your account for you. When you're done, |
|||
commit your change and open a [pull request][pull] against the `master` |
|||
branch. A maintainer reviews the pull request before merging it. |
|||
|
|||
## Making minor edits to existing topics |
|||
## Make a larger change |
|||
|
|||
To [edit an existing file][edit-file], navigate to it and click the "Edit" button. GitHub will |
|||
automatically create your own fork of our repository where you can make your changes. Once you are |
|||
finished, save your edits and submit a [pull request][pull] to the *staging* branch of the |
|||
[NTFSAccess-Docs][docs-repo] repository. After your pull request is created, someone on the |
|||
NTFSAccess documentation team reviews your changes before merging them into the *staging* branch. |
|||
For new pages, new images, or changes to many pages, work in your own clone: |
|||
|
|||
## Making major edits to existing topics |
|||
|
|||
If you are making significant changes, adding or changing images, or contributing a new article, you |
|||
need to create a GitHub fork and clone it to your computer. A fork is a GitHub-based replica of the |
|||
main repository, under your GitHub account, that provides you with a working copy which you can use |
|||
in isolation. You create pull requests from your fork. Similarly, a clone is a local-based replica |
|||
of the repository which, in this case, is a clone of your fork. The clone allows you to work on Git |
|||
repositories offline, and using more powerful native software/tools. |
|||
|
|||
Here is the workflow for making major edits to existing documentation: |
|||
|
|||
1. [Create a fork][fork] of the [NTFSAccess][docs-repo] repository. |
|||
2. [Create a clone of your fork][clone] on your local computer. |
|||
3. Create a new local branch in your cloned repository. |
|||
4. Make changes to the file(s) you want to update in a Markdown editor. |
|||
5. [Push your local branch][push] to your fork. |
|||
6. [Create a pull request][pull] to the *staging* branch of the [NTFSAccess-Docs][docs-repo] |
|||
repository. |
|||
1. [Fork][fork] the [NTFSSecurity repository][repo]. |
|||
2. [Clone][clone] your fork to your computer. |
|||
3. Create a branch in your clone. |
|||
4. Change the files in a Markdown editor. |
|||
5. [Push][push] the branch to your fork. |
|||
6. [Open a pull request][pull] against the `master` branch of |
|||
[raandree/NTFSSecurity][repo]. |
|||
|
|||
## Next steps |
|||
|
|||
See [Writing documentation](02-Writing.md). |
|||
See [Write documentation](02-Writing.md). |
|||
|
|||
<!-- External URLs --> |
|||
[git-help]: https://help.github.com/ |
|||
[new-issue]: https://help.github.com/articles/creating-an-issue/ |
|||
[doc-issues]: https://github.com/raandree/NTFSSecurity/issues |
|||
[edit-file]: https://help.github.com/articles/editing-files-in-another-user-s-repository/ |
|||
[docs-repo]: https://github.com/raandree/NTFSSecurity/ |
|||
[fork]: https://help.github.com/articles/fork-a-repo/ |
|||
[clone]: https://help.github.com/articles/cloning-a-repository/ |
|||
[push]: https://help.github.com/articles/pushing-to-a-remote/ |
|||
[pull]: https://help.github.com/articles/creating-a-pull-request/ |
|||
[git-help]: https://docs.github.com/en/get-started |
|||
[new-issue]: https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue |
|||
[issues]: https://github.com/raandree/NTFSSecurity/issues |
|||
[repo]: https://github.com/raandree/NTFSSecurity |
|||
[fork]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo |
|||
[clone]: https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository |
|||
[push]: https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository |
|||
[pull]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request |
|||
|
|||
@ -1,55 +1,122 @@ |
|||
# WRITING DOCUMENTATION |
|||
# Write documentation |
|||
|
|||
One of the easiest ways to contribute to the NTFSAccess PowerShell module is by helping to write and edit documentation. |
|||
All the documentation hosted on GitHub is written using *Markdown*. Markdown is a lightweight markup |
|||
language with plain text formatting syntax. Markdown forms the basis of our documentation's |
|||
conceptual authoring language. Creating new articles is as easy as writing a simple text file by |
|||
using your favorite text editor. |
|||
The NTFSSecurity documentation is written in Markdown and built into a |
|||
website with [MkDocs][mkdocs]. This page explains how the documentation is |
|||
organized and how to change it. |
|||
|
|||
## Documentation structure |
|||
|
|||
| Path | Content | |
|||
| --- | --- | |
|||
| `Docs/index.md` | Home page with features, requirements, and the cmdlet list | |
|||
| `Docs/Concepts.md` | Background on security descriptors, rights, inheritance, and privileges | |
|||
| `Docs/Examples.md` | Task-oriented examples | |
|||
| `Docs/Cmdlets/*.md` | One reference page per cmdlet, in platyPS format | |
|||
| `Docs/Contributing.md`, `Docs/Contributing/*.md` | This contributor guide | |
|||
| `mkdocs.yml` | Site settings and navigation | |
|||
| `.readthedocs.yml` | Build settings for Read the Docs | |
|||
| `README.md` | Front page of the GitHub repository | |
|||
|
|||
When you add a page, add it to the `nav` section of `mkdocs.yml`. |
|||
|
|||
## Markdown editors |
|||
|
|||
Here are some Markdown editors you can try out: |
|||
Any text editor works. These editors have good Markdown support: |
|||
|
|||
- [Visual Studio Code](https://code.visualstudio.com) with the |
|||
[markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) |
|||
extension |
|||
- [Sublime Text](https://www.sublimetext.com/) |
|||
|
|||
To get started with Markdown, see |
|||
[How to use Markdown for writing Docs](https://learn.microsoft.com/contribute/content/markdown-reference). |
|||
Don't use hard tabs. For the rules that apply to this repository, see |
|||
[Markdown and platyPS specifics](04-Markdown-Specifics.md). |
|||
|
|||
## Update the cmdlet reference |
|||
|
|||
The pages in `Docs/Cmdlets` are [platyPS][platyps] Markdown files. platyPS |
|||
reads the parameter metadata from the module, so the syntax and the parameter |
|||
details always match the code. You write the synopsis, the description, the |
|||
parameter descriptions, the examples, and the notes. |
|||
|
|||
When a cmdlet changes, build the module, import the build output, and update |
|||
the pages in Windows PowerShell 5.1. A Release build writes the module to |
|||
`NTFSSecurity\bin\Release`; the `before_build` and `build_script` steps in |
|||
`appveyor.yml` show the commands that the CI build uses: |
|||
|
|||
```powershell |
|||
Install-Module -Name platyPS -RequiredVersion 0.14.2 |
|||
Import-Module -Name .\NTFSSecurity\bin\Release\NTFSSecurity.psd1 |
|||
Update-MarkdownHelp -Path .\Docs\Cmdlets |
|||
``` |
|||
|
|||
`Update-MarkdownHelp` updates the syntax and the parameter metadata and keeps |
|||
the text that you wrote. Fill in the description of every new parameter. |
|||
|
|||
Use Windows PowerShell 5.1 for platyPS. In PowerShell 7.4 and later, |
|||
platyPS 0.14.2 adds the `-ProgressAction` common parameter to every page. |
|||
|
|||
For a new cmdlet, create the page, replace every placeholder in it, and add |
|||
the page to `mkdocs.yml`. Replace `Get-NTFSExample` with the name of the new |
|||
cmdlet: |
|||
|
|||
```powershell |
|||
New-MarkdownHelp -Command Get-NTFSExample -OutputFolder .\Docs\Cmdlets |
|||
``` |
|||
|
|||
To check that the pages can be converted to the help file that `Get-Help` |
|||
reads, run `New-ExternalHelp`: |
|||
|
|||
```powershell |
|||
New-ExternalHelp -Path .\Docs\Cmdlets -OutputPath $env:TEMP\NTFSSecurityHelp |
|||
``` |
|||
|
|||
## Preview the website |
|||
|
|||
- [Visual Studio Code](https://code.visualstudio.com) |
|||
- [Atom](https://atom.io/) |
|||
- [Sublime Text](http://www.sublimetext.com/) |
|||
MkDocs needs Python. Install the MkDocs version that the site is built with |
|||
and start the preview server: |
|||
|
|||
## Get started using Markdown |
|||
```powershell |
|||
pip install -r Docs/requirements.txt |
|||
mkdocs serve |
|||
``` |
|||
|
|||
To get started using Markdown, see [How to use Markdown for writing Docs](https://docs.microsoft.com/contribute/how-to-write-use-markdown). |
|||
Open `http://127.0.0.1:8000` in a browser. The preview reloads when you save |
|||
a file. Run `mkdocs build --strict` to find broken links and pages that are |
|||
missing from the navigation. |
|||
|
|||
NTFSSecurity uses the [Mkdocs][mkdocs] builder on ReadTheDocs for documentation. |
|||
## Check your change |
|||
|
|||
Don't use hard tabs in Markdown. For more detailed information about the Markdown specification, see the |
|||
[Markdown Specifics](04-Markdown-Specifics.md) article. |
|||
Before you open a pull request, check the following: |
|||
|
|||
## Creating new topics |
|||
- No page in `Docs/Cmdlets` contains a `{{ ... }}` placeholder. |
|||
- `Update-MarkdownHelp` doesn't change any page in `Docs/Cmdlets`. The build |
|||
defined in `appveyor.yml` runs the same check. |
|||
- All links work. The build checks them with `Get-MarkdownLink` from the |
|||
MarkdownLinkCheck module: |
|||
|
|||
To contribute new documentation, check for issues tagged as ["Help Wanted"][labels] to make sure |
|||
you're not duplicating efforts. If no one seems to be working on what you have planned: |
|||
```powershell |
|||
Get-MarkdownLink -Path .\Docs -BrokenOnly |
|||
``` |
|||
|
|||
- Open a new issue and label it as "in progress". If you don't have rights to assign labels, add "in |
|||
progress" as a comment to tell others what you're working on. |
|||
- Follow the same workflow as described above for making major edits to existing topics. |
|||
- Add your new article to the `TOC.yml` file (located in the top-level folder of each |
|||
documentation set). |
|||
- Every example works. Test examples in a test folder, never on production |
|||
data. |
|||
|
|||
## Updating topics that exist in multiple versions |
|||
## Create new topics |
|||
|
|||
Most reference topics are duplicated across all versions of PowerShell. When reporting an issue |
|||
about a cmdlet reference or an About_ article, you must specify which versions are affected by the |
|||
issue. The default issue template in GitHub includes a [GFM task list][gfm-task]. Use the checkboxes |
|||
in the task list to specify which versions of the content are affected. When you submit a change to |
|||
a article for an issue that affects multiple versions of the content, you must apply the appropriate |
|||
change to each version of the file. |
|||
Before you write a new topic, check the issues labeled |
|||
[Documentation][label-documentation] or [Help Wanted][label-help-wanted] to |
|||
make sure nobody else is working on it. If nobody is, open an issue that |
|||
describes the topic and say that you're working on it. Then follow the |
|||
workflow for larger changes in [Get started](01-Getting-Started.md). |
|||
|
|||
## Next Steps |
|||
## Next steps |
|||
|
|||
Read the [Style Guide](03-Style-Guide.md). |
|||
Read the [Style guide](03-Style-Guide.md). |
|||
|
|||
<!-- External URLs --> |
|||
[markdig]: https://github.com/lunet-io/markdig |
|||
[CommonMark]: https://spec.commonmark.org/ |
|||
[gfm-help]: https://help.github.com/categories/writing-on-github/ |
|||
[labels]: https://github.com/raandree/NTFSSecurity/labels/Help%20Wanted |
|||
[mkdocs]: https://www.mkdocs.org/user-guide/writing-your-docs/ |
|||
[platyps]: https://github.com/PowerShell/platyPS |
|||
[label-documentation]: https://github.com/raandree/NTFSSecurity/labels/Documentation |
|||
[label-help-wanted]: https://github.com/raandree/NTFSSecurity/labels/Help%20Wanted |
|||
|
|||
@ -0,0 +1,52 @@ |
|||
# Style guide |
|||
|
|||
Follow these rules so that the NTFSSecurity documentation reads as one |
|||
consistent set of pages. |
|||
|
|||
## Language |
|||
|
|||
- Write in American English, in the present tense, and in the active voice. |
|||
- Address the reader as "you". |
|||
- Keep sentences short, with one idea per sentence. |
|||
- Write product names as their owners do: PowerShell, Windows PowerShell, |
|||
NTFS, Active Directory, GitHub. |
|||
- Format cmdlet names, parameter names, values, type names, paths, and code |
|||
as code with backticks, for example `Add-NTFSAccess -AccessRights Modify`. |
|||
- Describe what the code does. Check every statement about behavior against |
|||
the source code or a test run. |
|||
|
|||
## Examples |
|||
|
|||
- Use the sample accounts `CONTOSO\JohnDoe`, `CONTOSO\Domain Users`, |
|||
`BUILTIN\Users`, and `BUILTIN\Administrators`. |
|||
- Use sample paths below `C:\Data`. |
|||
- Use full cmdlet names, full parameter names, and full value names, for |
|||
example `FullControl` instead of `Full`. Don't use aliases or positional |
|||
parameters unless the example is about them. |
|||
- Test every example in a test folder before you publish it. |
|||
- Don't publish output that shows real computer, domain, or user names. |
|||
Describe the result in a sentence instead. |
|||
- Say when an example needs an elevated session. |
|||
|
|||
## Cmdlet reference pages |
|||
|
|||
| Section | Content | |
|||
| --- | --- | |
|||
| SYNOPSIS | One sentence that starts with a verb in the third person, for example "Gets ..." or "Adds ...". | |
|||
| DESCRIPTION | What the cmdlet does, what it works on, how the parameter sets differ, defaults, and the module settings that affect it. | |
|||
| EXAMPLES | Two to four realistic tasks. Each example has a title, the command, and a sentence that explains the result. | |
|||
| PARAMETERS | "Specifies ..." for parameters that take a value and "Indicates that ..." for switches. Name the default when the parameter is omitted. | |
|||
| INPUTS and OUTPUTS | One sentence per type. Say when the cmdlet writes nothing by default. | |
|||
| NOTES | Required privileges, limitations, and differences between versions. | |
|||
| RELATED LINKS | Links to closely related cmdlet pages. | |
|||
|
|||
## Conceptual pages |
|||
|
|||
- Use one level 1 heading per page and sentence case for all headings. |
|||
- Start each page with a short introduction that says what the page covers. |
|||
- Wrap lines at 80 characters, except in tables, links, and code blocks. |
|||
- Link to the cmdlet reference instead of repeating parameter details. |
|||
|
|||
## Next steps |
|||
|
|||
Read [Markdown and platyPS specifics](04-Markdown-Specifics.md). |
|||
@ -0,0 +1,48 @@ |
|||
# Markdown and platyPS specifics |
|||
|
|||
This page lists the Markdown rules for the NTFSSecurity documentation and |
|||
the additional rules for the cmdlet reference pages, which platyPS processes. |
|||
|
|||
## Markdown |
|||
|
|||
- Use ATX headings (`#`), one level 1 heading per page, and don't skip |
|||
heading levels. |
|||
- Use `-` for bulleted lists and `1.` for numbered lists. |
|||
- Surround headings, lists, tables, and code blocks with blank lines. |
|||
- Give every fenced code block a language, for example `powershell`. |
|||
- Don't use hard tabs or trailing spaces. |
|||
- Link to other pages with relative links to the `.md` file, for example |
|||
`[Concepts](Concepts.md)` or `[Get-NTFSAccess](Cmdlets/Get-NTFSAccess.md)`. |
|||
MkDocs converts them to links to the generated pages. |
|||
- End every file with a single newline. |
|||
|
|||
## Cmdlet reference pages |
|||
|
|||
platyPS converts the pages in `Docs/Cmdlets` to help files and updates them |
|||
from the module. Keep the structure that platyPS expects: |
|||
|
|||
- Keep the front matter. `external help file`, `Module Name`, and `schema` |
|||
must stay as they are. `online version` is the address of the page on |
|||
GitHub, which `Get-Help -Online` opens. |
|||
- Keep the level 2 headings in capital letters and in this order: SYNOPSIS, |
|||
SYNTAX, DESCRIPTION, EXAMPLES, PARAMETERS, INPUTS, OUTPUTS, NOTES, |
|||
RELATED LINKS. Don't add other level 2 headings. |
|||
- Don't edit the SYNTAX blocks or the YAML block of a parameter by hand. |
|||
platyPS regenerates them from the module. The only exception is |
|||
`Default value`, which platyPS keeps. |
|||
- Write each paragraph on a single line. platyPS carries line breaks into the |
|||
text that `Get-Help` shows. |
|||
- Start each example with a level 3 heading such as |
|||
`### Example 1: Get the permissions of a folder`, followed by a code block |
|||
with the language `PowerShell` whose first line starts with `PS C:\>`. |
|||
- Under INPUTS and OUTPUTS, keep the level 3 headings with the type names and |
|||
add a sentence below each one. |
|||
- In RELATED LINKS, write each link on its own line and separate the links |
|||
with blank lines. |
|||
|
|||
## MkDocs |
|||
|
|||
- The site uses the built-in `readthedocs` theme. |
|||
- Every page must be listed in the `nav` section of `mkdocs.yml`. |
|||
- Files in `Docs` that aren't Markdown are copied to the website. Exclude |
|||
files that don't belong there with `exclude_docs` in `mkdocs.yml`. |
|||
@ -1,93 +1,222 @@ |
|||
### Get-NTFSAccess |
|||
Returns a list of all access control entries found on the given object(s). |
|||
# Examples |
|||
|
|||
#Get permissions from all files or folders in the current folder |
|||
dir | Get-NTFSAccess |
|||
These examples show common tasks with the NTFSSecurity module. Replace the |
|||
sample paths and accounts with your own. For background, see |
|||
[Concepts](Concepts.md). |
|||
|
|||
#to read the permissions of a specific file |
|||
Get-NTFSAccess -Path C:\Windows |
|||
Changing permissions on items you don't own, changing owners, and every |
|||
audit operation need an elevated PowerShell session. See |
|||
[Privileges](Concepts.md#privileges). |
|||
|
|||
#### Get permissions from all files or folders in the current folder |
|||
## Read permissions |
|||
|
|||
dir | Get-NTFSAccess |
|||
Get the access entries of a folder: |
|||
|
|||
#### To read and also remove only the explicitly assigned ones |
|||
```powershell |
|||
Get-NTFSAccess -Path C:\Data |
|||
``` |
|||
|
|||
dir | Get-NTFSAccess -ExcludeInherited | Remove-NTFSAccess |
|||
Get the access entries of every item in a folder: |
|||
|
|||
The pipeline support can also be used to backup and restore permissions of one or many items: |
|||
PowerShell |
|||
```powershell |
|||
Get-ChildItem -Path C:\Data | Get-NTFSAccess |
|||
``` |
|||
|
|||
#### To backup permissions just pipe what Get-NTFSAccess returns to Export-Csv |
|||
Get only the explicit entries in a folder tree, including items with paths |
|||
longer than 260 characters: |
|||
|
|||
dir | Get-NTFSAccess -ExcludeInherited | Export-Csv permissions.csv |
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSAccess -ExcludeInherited |
|||
``` |
|||
|
|||
#### To retore the permissions pipe the imported data to Get-NTFSAccess |
|||
Get the entries of one account, either with `-Account` or with |
|||
`Where-Object`: |
|||
|
|||
As the imported data also contains the path you do not need to specify the item |
|||
```powershell |
|||
Get-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' |
|||
Get-NTFSAccess -Path C:\Data | Where-Object { $_.Account -like '*JohnDoe*' } |
|||
``` |
|||
|
|||
Import-Csv .\permissions.csv | Get-NTFSAccess |
|||
## Grant permissions |
|||
|
|||
All cmdlets can handle SIDs and also SamAccountNames. The output contains always both unless a SID is not resolvable. |
|||
The types.ps1xml file is extending the common objects with some useful information and the format.ps1xml file formats all the output in almost the same way like the Get-ChildItem output. |
|||
Give an account the Modify permission on a folder, its subfolders, and its |
|||
files: |
|||
|
|||
By implementing the [Process Privilege http://processprivileges.codeplex.com/] project the cmdlets can activate the required privileges for setting the ownership for example. |
|||
```powershell |
|||
Add-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' -AccessRights Modify |
|||
``` |
|||
|
|||
Give a group read access to a folder and its subfolders, but not to the |
|||
files: |
|||
|
|||
# Add-NTFSAccess |
|||
Adds a specific ace to the current object. This can be done in just one line: |
|||
```powershell |
|||
Add-NTFSAccess -Path C:\Data -Account 'CONTOSO\Domain Users' -AccessRights ReadAndExecute -AppliesTo ThisFolderAndSubfolders |
|||
``` |
|||
|
|||
Get-Item .\VMWare | Add-NTFSAccess -Account Contoso\JohnD -AccessRights FullControl |
|||
Deny a group the right to delete anything in a folder: |
|||
|
|||
# Get-NTFSAccess |
|||
```powershell |
|||
Add-NTFSAccess -Path C:\Data\Public -Account 'CONTOSO\Interns' -AccessRights Delete, DeleteSubdirectoriesAndFiles -AccessType Deny |
|||
``` |
|||
|
|||
Gives you a list of all permissions . normally you are interested not in the inherited permissions so the switch ExcludeInherited can be useful |
|||
## Remove permissions |
|||
|
|||
Get-Item F:\backup | Get-NTFSAccess –ExcludeInherited |
|||
Remove an entry by account and rights: |
|||
|
|||
```powershell |
|||
Remove-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' -AccessRights Modify |
|||
``` |
|||
|
|||
## Filtering works with Where-Object |
|||
Remove all explicit entries of an account by piping them to |
|||
`Remove-NTFSAccess`: |
|||
|
|||
Get-Item F:\backup | Get-NTFSAccess | Where-Object { $_.ID -like "*users*" } |
|||
```powershell |
|||
Get-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' -ExcludeInherited | Remove-NTFSAccess |
|||
``` |
|||
|
|||
# Get-NTFS Orphaned Access |
|||
## Back up and restore permissions |
|||
|
|||
Lists all permissions that can no longer be resolved. This normally happens if the account is no longer available so the permissions show up as a SID and not as an account name. |
|||
Save the explicit entries of a folder and everything below it to a CSV file: |
|||
|
|||
To remove all non-resolvable or orphaned permissions you can use the following line. But be very careful with that as maybe the account is not resolvable due to a network problem. |
|||
```powershell |
|||
$items = @(Get-Item2 -Path C:\Data) + @(Get-ChildItem2 -Path C:\Data -Recurse) |
|||
$items | Get-NTFSAccess -ExcludeInherited | Export-Csv -Path C:\Backup\permissions.csv -NoTypeInformation |
|||
``` |
|||
|
|||
dir -Recurse | Get-NTFSOrphanedAccess | Remove-NTFSAccess |
|||
Restore the entries. Each row contains the path, account, rights, type, and |
|||
inheritance settings of one entry, which `Add-NTFSAccess` binds by property |
|||
name: |
|||
|
|||
# Remove- NTFSAccess |
|||
```powershell |
|||
Import-Csv -Path C:\Backup\permissions.csv | Add-NTFSAccess |
|||
``` |
|||
|
|||
Removes the permission for a certain account. As the pipeline is supported it takes also |
|||
ACEs coming from Get-NTFSAccess or Get-NTFSOrphanedAccess |
|||
Restoring adds the saved entries. It doesn't remove entries that were added |
|||
after the backup. |
|||
|
|||
## Find and remove orphaned entries |
|||
|
|||
# Get-NTFSEffectiveAccess |
|||
List entries whose account no longer exists: |
|||
|
|||
Shows the permissions an account actually has on a file or folder. If no parameter is specified it shows the effective permissions for the current user. However you can supply a user by using the SID or account name |
|||
PowerShell |
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSOrphanedAccess |
|||
``` |
|||
|
|||
Get-Item F:\backup | Get-NTFSEffectiveAccess -Account S-1-5-32-545 |
|||
Remove them: |
|||
|
|||
# Get-NTFSInheritance |
|||
Shows if inheritance is blocked |
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSOrphanedAccess | Remove-NTFSAccess |
|||
``` |
|||
|
|||
# Enable-NTFSInheritance |
|||
It can be a problem if certain files or folders on a volume have inheritance disabled. Making sure that inheritance is enabled can be done using this cmdlets: |
|||
Review the list before you remove anything. An account also looks orphaned |
|||
when Windows can't resolve it temporarily, for example because a domain |
|||
controller is unreachable. |
|||
|
|||
Get-Item .\Data -Recurse | Enable-NTFSAccessInheritance |
|||
## Check effective access |
|||
|
|||
# Disable-NTFSInheritance |
|||
See Enable-NTFSInheritance |
|||
Show the access that the current user has on a folder: |
|||
|
|||
# Get-NTFSOwner |
|||
Shows the owner of a file or folder |
|||
```powershell |
|||
Get-NTFSEffectiveAccess -Path C:\Data |
|||
``` |
|||
|
|||
dir -Recurse | Get-NTFSOwner |
|||
Show the access of another account, by name or by SID: |
|||
|
|||
# Set-NTFSOwner |
|||
Sets the owner to a specific account like: |
|||
```powershell |
|||
Get-NTFSEffectiveAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' |
|||
Get-NTFSEffectiveAccess -Path C:\Data -Account S-1-5-32-545 |
|||
``` |
|||
|
|||
Get-Item .\Data | Set-NTFSOwner -Account builtin\administrators |
|||
## Manage inheritance |
|||
|
|||
Find the folders that don't inherit permissions from their parent: |
|||
|
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse -Directory | Get-NTFSInheritance | Where-Object { -not $_.AccessInheritanceEnabled } |
|||
``` |
|||
|
|||
Turn inheritance back on for a whole folder tree. Explicit entries stay in |
|||
place: |
|||
|
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Enable-NTFSAccessInheritance |
|||
``` |
|||
|
|||
Block inheritance on a folder. The inherited entries are copied as explicit |
|||
entries: |
|||
|
|||
```powershell |
|||
Disable-NTFSAccessInheritance -Path C:\Data\Finance |
|||
``` |
|||
|
|||
Reset a folder to inherited permissions only: |
|||
|
|||
```powershell |
|||
Enable-NTFSAccessInheritance -Path C:\Data\Finance -RemoveExplicitAccessRules |
|||
``` |
|||
|
|||
## Manage ownership |
|||
|
|||
List the owners of all items in a folder tree: |
|||
|
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSOwner |
|||
``` |
|||
|
|||
Make the local Administrators group the owner of a folder. This needs an |
|||
elevated session: |
|||
|
|||
```powershell |
|||
Set-NTFSOwner -Path C:\Data -Account 'BUILTIN\Administrators' |
|||
``` |
|||
|
|||
## Make several changes in one write |
|||
|
|||
Get the security descriptor once, change it in memory, and write it back. |
|||
With security descriptor input, specify `-AppliesTo` (or the inheritance and |
|||
propagation flags) so that PowerShell can choose the parameter set: |
|||
|
|||
```powershell |
|||
$sd = Get-NTFSSecurityDescriptor -Path C:\Data |
|||
$sd | Add-NTFSAccess -Account 'CONTOSO\JohnDoe' -AccessRights Modify -AppliesTo ThisFolderSubfoldersAndFiles |
|||
$sd | Remove-NTFSAccess -Account 'CONTOSO\Interns' -AccessRights ReadAndExecute -AppliesTo ThisFolderSubfoldersAndFiles |
|||
$sd | Set-NTFSSecurityDescriptor |
|||
``` |
|||
|
|||
## Audit access |
|||
|
|||
Log every successful and failed attempt to delete items in a folder. This |
|||
needs an elevated session, and Windows only writes the events when the |
|||
**Audit File System** policy is enabled: |
|||
|
|||
```powershell |
|||
Add-NTFSAudit -Path C:\Data\Finance -Account 'Everyone' -AccessRights Delete, DeleteSubdirectoriesAndFiles |
|||
Get-NTFSAudit -Path C:\Data\Finance |
|||
``` |
|||
|
|||
## Work with long paths |
|||
|
|||
Find files whose full path is longer than 260 characters and show their |
|||
permissions: |
|||
|
|||
```powershell |
|||
Get-ChildItem2 -Path C:\Data -Recurse -File | Where-Object { $_.FullName.Length -gt 260 } | Get-NTFSAccess |
|||
``` |
|||
|
|||
## Use privileges |
|||
|
|||
List the privileges of the current PowerShell process: |
|||
|
|||
```powershell |
|||
Get-Privileges |
|||
``` |
|||
|
|||
In an elevated session, enable the Backup, Restore, Take Ownership, and |
|||
Security privileges for the rest of the session, and disable them again |
|||
when you're done: |
|||
|
|||
```powershell |
|||
Enable-Privileges |
|||
Get-ChildItem2 -Path D:\Shares -Recurse | Get-NTFSAccess -ExcludeInherited |
|||
Disable-Privileges |
|||
``` |
|||
|
|||
@ -1,31 +1,153 @@ |
|||
# NTFSSecurity |
|||
|
|||
[](https://ci.appveyor.com/project/Sup3rlativ3/ntfssecurity) [](https://ntfssecurity.readthedocs.io/en/latest/?badge=latest) |
|||
NTFSSecurity is a PowerShell module for managing the permissions, audit |
|||
settings, inheritance, and ownership of files and folders on NTFS volumes. |
|||
|
|||
Managing file & folder permissions with PowerShell is only a bit easier than in VBS or the command line as there are no cmdlets for most day-to-day tasks like getting a permission report or adding permission to an item. PowerShell only offers Get-Acl and Set-Acl but everything in between getting and setting the ACL is missing. This module closes the gap. |
|||
PowerShell offers only `Get-Acl` and `Set-Acl`; everything between reading |
|||
and writing an access control list is up to you. NTFSSecurity closes this gap |
|||
with task-level cmdlets that work with the PowerShell pipeline. |
|||
|
|||
[Version History](https://github.com/raandree/NTFSSecurity/wiki/Version-History) |
|||
## Features |
|||
|
|||
## Installation |
|||
- Read, add, remove, and clear access entries and audit entries. |
|||
- Show the effective access of an account and find orphaned entries. |
|||
- Inspect, enable, and disable inheritance. |
|||
- Get and set the owner of files and folders. |
|||
- Change several entries in memory and write them in one step. |
|||
- Enable the Backup, Restore, Take Ownership, and Security privileges to |
|||
work on items that you can't otherwise access. |
|||
- Work with paths longer than 260 characters. |
|||
- Create hard links and symbolic links, list the hard links of a file, and |
|||
get file hashes and disk space. |
|||
|
|||
## Requirements |
|||
|
|||
You have two options: |
|||
- Windows with NTFS volumes. |
|||
- Windows PowerShell 5.1 or PowerShell 7. `Get-FileHash2` works only in |
|||
Windows PowerShell. |
|||
- An elevated session for audit operations, owner changes, and access to |
|||
items that your account can't open. See |
|||
[Privileges](Concepts.md#privileges). |
|||
|
|||
## Installation |
|||
|
|||
* Download the latest release from the [releases](https://github.com/raandree/NTFSSecurity/releases) section on GitHub. |
|||
* Download the module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/NTFSSecurity): |
|||
Install the module from the |
|||
[PowerShell Gallery](https://www.powershellgallery.com/packages/NTFSSecurity): |
|||
|
|||
```PowerShell |
|||
```powershell |
|||
Install-Module -Name NTFSSecurity |
|||
``` |
|||
|
|||
Further help can be found in How to install if you face difficulties getting this module installed. |
|||
You can also download a release from the |
|||
[releases page](https://github.com/raandree/NTFSSecurity/releases) on GitHub. |
|||
If you have trouble, see |
|||
[How to install](https://github.com/raandree/NTFSSecurity/wiki/How-to-install). |
|||
|
|||
## Getting started |
|||
|
|||
```powershell |
|||
Import-Module -Name NTFSSecurity |
|||
Get-Command -Module NTFSSecurity |
|||
Get-NTFSAccess -Path C:\Windows |
|||
``` |
|||
|
|||
Read [Concepts](Concepts.md) for the background and [Examples](Examples.md) |
|||
for common tasks. Every cmdlet has a reference page with all parameters and |
|||
examples; see the [cmdlet list](#cmdlets). |
|||
|
|||
## Cmdlets |
|||
|
|||
### Permissions |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-NTFSAccess](Cmdlets/Get-NTFSAccess.md) | Gets the access control entries (ACEs) of a file, a folder, or a security descriptor. | |
|||
| [Add-NTFSAccess](Cmdlets/Add-NTFSAccess.md) | Adds an access control entry (ACE) to a file, a folder, or a security descriptor. | |
|||
| [Remove-NTFSAccess](Cmdlets/Remove-NTFSAccess.md) | Removes rights from the access control entries (ACEs) of a file, a folder, or a security descriptor. | |
|||
| [Clear-NTFSAccess](Cmdlets/Clear-NTFSAccess.md) | Removes all explicit access control entries from a file or folder. | |
|||
| [Get-NTFSEffectiveAccess](Cmdlets/Get-NTFSEffectiveAccess.md) | Gets the rights an account effectively has on a file or folder. | |
|||
| [Get-NTFSOrphanedAccess](Cmdlets/Get-NTFSOrphanedAccess.md) | Gets the access control entries whose account cannot be resolved to a name. | |
|||
| [Get-NTFSSimpleAccess](Cmdlets/Get-NTFSSimpleAccess.md) | Gets the permissions of folders reduced to read, write, and delete. | |
|||
|
|||
### Auditing |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-NTFSAudit](Cmdlets/Get-NTFSAudit.md) | Gets the audit entries of a file or folder. | |
|||
| [Add-NTFSAudit](Cmdlets/Add-NTFSAudit.md) | Adds an audit entry to a file or folder. | |
|||
| [Remove-NTFSAudit](Cmdlets/Remove-NTFSAudit.md) | Removes an audit entry from a file or folder. | |
|||
| [Clear-NTFSAudit](Cmdlets/Clear-NTFSAudit.md) | Removes all explicit audit entries from a file or folder. | |
|||
| [Get-NTFSOrphanedAudit](Cmdlets/Get-NTFSOrphanedAudit.md) | Gets the audit entries whose account cannot be resolved. | |
|||
|
|||
### Inheritance |
|||
|
|||
## Documentation |
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-NTFSInheritance](Cmdlets/Get-NTFSInheritance.md) | Gets the inheritance state of the access rules and the audit rules of a file or folder. | |
|||
| [Set-NTFSInheritance](Cmdlets/Set-NTFSInheritance.md) | Sets the inheritance of the access rules and the audit rules of a file or folder. | |
|||
| [Enable-NTFSAccessInheritance](Cmdlets/Enable-NTFSAccessInheritance.md) | Restores the inheritance of access rules on a file or folder. | |
|||
| [Disable-NTFSAccessInheritance](Cmdlets/Disable-NTFSAccessInheritance.md) | Blocks the inheritance of access rules on a file or folder. | |
|||
| [Enable-NTFSAuditInheritance](Cmdlets/Enable-NTFSAuditInheritance.md) | Restores the inheritance of audit rules on a file or folder. | |
|||
| [Disable-NTFSAuditInheritance](Cmdlets/Disable-NTFSAuditInheritance.md) | Blocks the inheritance of audit rules on a file or folder. | |
|||
|
|||
The cmdlets are yet not documented completely so Get-Help will not show help for all the cmdlets. This ReadTheDocs site is the first step to documenting the module. |
|||
### Owner and security descriptor |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-NTFSOwner](Cmdlets/Get-NTFSOwner.md) | Gets the owner of a file or folder. | |
|||
| [Set-NTFSOwner](Cmdlets/Set-NTFSOwner.md) | Sets the owner of a file or folder. | |
|||
| [Get-NTFSSecurityDescriptor](Cmdlets/Get-NTFSSecurityDescriptor.md) | Gets the security descriptor of a file or folder. | |
|||
| [Set-NTFSSecurityDescriptor](Cmdlets/Set-NTFSSecurityDescriptor.md) | Writes a security descriptor to the file or folder it was read from. | |
|||
|
|||
### Privileges |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-Privileges](Cmdlets/Get-Privileges.md) | Gets the privileges in the access token of the current PowerShell process. | |
|||
| [Enable-Privileges](Cmdlets/Enable-Privileges.md) | Enables the file system privileges in the access token of the current PowerShell process. | |
|||
| [Disable-Privileges](Cmdlets/Disable-Privileges.md) | Disables the file system privileges in the access token of the current PowerShell process. | |
|||
|
|||
### Files and folders with long paths |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-ChildItem2](Cmdlets/Get-ChildItem2.md) | Gets the files and folders in one or more folders, including paths longer than 260 characters. | |
|||
| [Get-Item2](Cmdlets/Get-Item2.md) | Gets the file or folder at a specified path, including paths longer than 260 characters. | |
|||
| [Copy-Item2](Cmdlets/Copy-Item2.md) | Copies a file to another location, including paths longer than 260 characters. | |
|||
| [Move-Item2](Cmdlets/Move-Item2.md) | Moves a file or folder to another location, including paths longer than 260 characters. | |
|||
| [Remove-Item2](Cmdlets/Remove-Item2.md) | Deletes a file or folder, including paths longer than 260 characters. | |
|||
| [Test-Path2](Cmdlets/Test-Path2.md) | Determines whether a file or folder exists at the specified path. | |
|||
|
|||
### Links, hashes, and disk space |
|||
|
|||
| Cmdlet | Description | |
|||
| --- | --- | |
|||
| [Get-NTFSHardLink](Cmdlets/Get-NTFSHardLink.md) | Gets all hard links that refer to the same file as the specified path. | |
|||
| [New-NTFSHardLink](Cmdlets/New-NTFSHardLink.md) | Creates a hard link to an existing file. | |
|||
| [New-NTFSSymbolicLink](Cmdlets/New-NTFSSymbolicLink.md) | Creates a symbolic link to an existing file or folder. | |
|||
| [Get-FileHash2](Cmdlets/Get-FileHash2.md) | Gets the hash value of one or more files. | |
|||
| [Get-DiskSpace](Cmdlets/Get-DiskSpace.md) | Gets size, free space, and cluster information for the volumes of a computer. | |
|||
|
|||
## Tutorials |
|||
|
|||
There are a number of tutorials available on the web. The below two were written by the author of the NTFSSecurity module. |
|||
The author of the module wrote two tutorials in 2014. Some cmdlet names in |
|||
them have changed since; use the cmdlet reference for the current names. |
|||
|
|||
- [NTFSSecurity Tutorial 1 - Getting, adding and removing permissions](https://learn.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-1-getting-adding-and-removing-permissions) |
|||
- [NTFSSecurity Tutorial 2 - Managing NTFS Inheritance and Using Privileges](https://learn.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-2-managing-ntfs-inheritance-and-using-privileges) |
|||
|
|||
## Version history |
|||
|
|||
See the [changelog](https://github.com/raandree/NTFSSecurity/blob/master/CHANGELOG.md) |
|||
and the |
|||
[version history](https://github.com/raandree/NTFSSecurity/wiki/Version-History) |
|||
in the wiki. |
|||
|
|||
## Contributing |
|||
|
|||
Contributions are welcome. See the [contributor guide](Contributing.md). |
|||
|
|||
## License |
|||
|
|||
[NTFSSecurity Tutorial 1 - Getting, adding and removing permissions](http://blogs.technet.com/b/fieldcoding/archive/2014/12/05/ntfssecurity-tutorial-1-getting-adding-and-removing-permissions.aspx) |
|||
[NTFSSecurity Tutorial 2 - Managing NTFS Inheritance and Using Privileges](http://blogs.technet.com/b/fieldcoding/archive/2014/12/05/ntfssecurity-tutorial-2-managing-ntfs-inheritance-and-using-privileges.aspx) |
|||
NTFSSecurity is licensed under the |
|||
[MIT license](https://github.com/raandree/NTFSSecurity/blob/master/LICENSE). |
|||
|
|||
@ -0,0 +1 @@ |
|||
mkdocs==1.6.1 |
|||
@ -1,21 +1,67 @@ |
|||
### Summary |
|||
Managing permissions with PowerShell is only a bit easier than in VBS or the command line as there are no cmdlets for most day-to-day tasks like getting a permission report or adding permission to an item. PowerShell only offers Get-Acl and Set-Acl but everything in between getting and setting the ACL is missing. This module closes the gap. |
|||
# NTFSSecurity |
|||
|
|||
### [Version History](https://github.com/raandree/NTFSSecurity/wiki/Version-History) |
|||
A PowerShell module for managing the permissions, audit settings, |
|||
inheritance, and ownership of files and folders on NTFS volumes. |
|||
|
|||
### Installation |
|||
You have two options: |
|||
1. Download the latest release from [the releases section](https://github.com/raandree/NTFSSecurity/releases). |
|||
2. Download the module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/NTFSSecurity): Install-Module -Name NTFSSecurity |
|||
PowerShell offers only `Get-Acl` and `Set-Acl`; everything between reading |
|||
and writing an access control list is up to you. NTFSSecurity closes this gap |
|||
with cmdlets for everyday tasks, such as permission reports, adding or |
|||
removing a single permission, repairing inheritance, and taking ownership. |
|||
|
|||
Further help can be found in [How to install](https://github.com/raandree/NTFSSecurity/wiki/How-to-install) if you face difficulties getting this module installed. |
|||
## Installation |
|||
|
|||
### Documentation |
|||
The cmdlets are documented in Docs/. |
|||
They are not documented completely so Get-Help will not show help for all the cmdlets. Providing documentation is planned though. |
|||
Install the module from the |
|||
[PowerShell Gallery](https://www.powershellgallery.com/packages/NTFSSecurity): |
|||
|
|||
See [Examples](Docs/Examples.md) for some usage examples. |
|||
```powershell |
|||
Install-Module -Name NTFSSecurity |
|||
``` |
|||
|
|||
Additional documentation is available: |
|||
* [NTFSSecurity Tutorial 1 - Getting, adding and removing permissions](https://docs.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-1-getting-adding-and-removing-permissions) |
|||
* [NTFSSecurity Tutorial 2 - Managing NTFS Inheritance and Using Privileges](https://docs.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-2-managing-ntfs-inheritance-and-using-privileges) |
|||
You can also download a release from the |
|||
[releases page](https://github.com/raandree/NTFSSecurity/releases). If you |
|||
have trouble, see |
|||
[How to install](https://github.com/raandree/NTFSSecurity/wiki/How-to-install). |
|||
|
|||
The module runs on Windows in Windows PowerShell 5.1 and PowerShell 7. |
|||
|
|||
## Quick start |
|||
|
|||
```powershell |
|||
# Show the permissions of a folder |
|||
Get-NTFSAccess -Path C:\Data |
|||
|
|||
# Give an account the Modify permission on a folder, its subfolders, and files |
|||
Add-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' -AccessRights Modify |
|||
|
|||
# Remove the explicit permissions of that account again |
|||
Get-NTFSAccess -Path C:\Data -Account 'CONTOSO\JohnDoe' -ExcludeInherited | |
|||
Remove-NTFSAccess |
|||
|
|||
# List the explicit permissions in a folder tree, including long paths |
|||
Get-ChildItem2 -Path C:\Data -Recurse | Get-NTFSAccess -ExcludeInherited |
|||
``` |
|||
|
|||
## Documentation |
|||
|
|||
- [Overview](Docs/index.md): features, requirements, and the list of cmdlets |
|||
- [Concepts](Docs/Concepts.md): security descriptors, access rights, |
|||
inheritance, privileges, long paths, and module settings |
|||
- [Examples](Docs/Examples.md): common tasks |
|||
- [Cmdlet reference](Docs/Cmdlets): one page per cmdlet |
|||
- [Contributor guide](Docs/Contributing.md) |
|||
|
|||
The module author's tutorials from 2014 are still a good introduction, |
|||
although some cmdlet names have changed since: |
|||
|
|||
- [NTFSSecurity Tutorial 1 - Getting, adding and removing permissions](https://learn.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-1-getting-adding-and-removing-permissions) |
|||
- [NTFSSecurity Tutorial 2 - Managing NTFS Inheritance and Using Privileges](https://learn.microsoft.com/en-us/archive/blogs/fieldcoding/ntfssecurity-tutorial-2-managing-ntfs-inheritance-and-using-privileges) |
|||
|
|||
## Version history |
|||
|
|||
See [CHANGELOG.md](CHANGELOG.md) for changes since version 4.2.6 and the |
|||
[version history](https://github.com/raandree/NTFSSecurity/wiki/Version-History) |
|||
in the wiki for earlier releases. |
|||
|
|||
## License |
|||
|
|||
NTFSSecurity is licensed under the [MIT license](LICENSE). |
|||
|
|||
@ -1,31 +1,48 @@ |
|||
install: |
|||
- ps: | |
|||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force |
|||
Install-Module platyPS -Force |
|||
Install-Module MarkdownLinkCheck -Force |
|||
Install-Module NTFSSecurity -Force |
|||
Import-Module platyPS |
|||
Import-Module MarkdownLinkCheck |
|||
# Builds the NTFSSecurity module from source and checks that the cmdlet |
|||
# documentation in Docs/Cmdlets matches the cmdlets of that build. |
|||
image: Visual Studio 2022 |
|||
|
|||
init: |
|||
- ps: git config --global core.autocrlf true |
|||
|
|||
install: |
|||
- ps: | |
|||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 |
|||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null |
|||
Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force |
|||
Install-Module -Name MarkdownLinkCheck -RequiredVersion 0.2.0 -Force |
|||
|
|||
before_build: |
|||
- nuget restore NTFSSecurity\packages.config -PackagesDirectory packages -NonInteractive |
|||
- nuget restore Security2\packages.config -PackagesDirectory packages -NonInteractive |
|||
# Provides the .NET Framework 4.5.2 reference assemblies, so the build does |
|||
# not depend on a targeting pack installed on the build image. |
|||
- nuget install Microsoft.NETFramework.ReferenceAssemblies.net452 -Version 1.0.3 -OutputDirectory packages -NonInteractive |
|||
|
|||
build_script: |
|||
- ps: Import-Module -Force NTFSSecurity |
|||
- ps: | |
|||
$referenceAssemblies = "$env:APPVEYOR_BUILD_FOLDER\packages\Microsoft.NETFramework.ReferenceAssemblies.net452.1.0.3\build" |
|||
msbuild NTFSSecurity\NTFSSecurity.csproj /nologo /verbosity:minimal /p:Configuration=Release "/p:TargetFrameworkRootPath=$referenceAssemblies" "/p:FrameworkPathOverride=$referenceAssemblies\.NETFramework\v4.5.2" |
|||
if ($LASTEXITCODE -ne 0) { |
|||
throw "MSBuild failed with exit code $LASTEXITCODE." |
|||
} |
|||
|
|||
test_script: |
|||
- ps: | |
|||
$ErrorActionPreference = 'Stop' |
|||
Import-Module -Name platyPS |
|||
Import-Module -Name MarkdownLinkCheck |
|||
Import-Module -Name .\NTFSSecurity\bin\Release\NTFSSecurity.psd1 -Force |
|||
|
|||
# 01. Test that documentation is up-to-date |
|||
Update-MarkdownHelp -Path ./Docs/Cmdlets |
|||
$Diff = git diff |
|||
if ($Diff) { |
|||
# 01. Test that the documentation matches the cmdlets built from source |
|||
Update-MarkdownHelp -Path ./Docs/Cmdlets | Out-Null |
|||
$diff = git diff -- Docs/Cmdlets |
|||
if ($diff) { |
|||
throw "Help is not up-to-date, run Update-MarkdownHelp: $diff" |
|||
} |
|||
|
|||
# 02. Verify hyperlinks |
|||
$BrokenLinks = Get-MarkdownLink -Path .\Docs\ -BrokenOnly |
|||
$brokenLinks = Get-MarkdownLink -Path .\Docs\ -BrokenOnly |
|||
if ($brokenLinks) { |
|||
throw "Found broken hyperlinks $brokenLinks" |
|||
} |
|||
Loading…
Reference in new issue