Copy-sqmNTFSPermissions
Filesystem
sqmSQLTool v1.8.2+ · Copy
✓ -WhatIf supported
-SourcePath and applies them to the corresponding object at the same relative path below -DestinationPath.
The target structure must already exist. With
-CreateMissingFolders, missing destination directories are created automatically (files that have no match at the destination are always skipped with a warning). Access errors during Get-Acl or Set-Acl produce warnings and processing continues.
All write operations (
New-Item and Set-Acl) are individually guarded by ShouldProcess, so -WhatIf shows what would happen without making any changes. Requires administrative rights.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SourcePath | string | Required | — | Source root path. Must be an existing container (validated by ValidateScript). |
| -DestinationPath | string | Required | — | Destination root path. Must exist unless -CreateMissingFolders is set. |
| -Recurse | switch | Switch | $false | Process all sub-folders and files recursively. Without this switch only the root item is processed. |
| -CreateMissingFolders | switch | Switch | $false | Automatically create missing destination directories (ShouldProcess-guarded). Missing files are still skipped. |
| -IncludeSystemAndHidden | switch | Switch | $false | Pass -Force to Get-Item / Get-ChildItem to include hidden and system objects. |
| -WhatIf / -Confirm | switch | Optional | — | All New-Item and Set-Acl calls are ShouldProcess-guarded. |
Execution Flow
Examples
Copy all permissions from D: to E: recursively
Copy-sqmNTFSPermissions -SourcePath "D:\" -DestinationPath "E:\" -Recurse
Copy permissions and create missing destination folders
Copy-sqmNTFSPermissions -SourcePath "D:\Data" -DestinationPath "E:\Data" -Recurse -CreateMissingFolders
Preview what would change without applying anything
Copy-sqmNTFSPermissions -SourcePath "D:\Data" -DestinationPath "E:\Data" -Recurse -WhatIf