Commands / Copy-sqmNTFSPermissions
Copy-sqmNTFSPermissions
Filesystem sqmSQLTool v1.8.2+ · Copy ✓ -WhatIf supported
Reads the explicit NTFS permissions (ACLs) from every file system object below -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

ParameterTypeRequiredDefaultNotes
-SourcePathstringRequiredSource root path. Must be an existing container (validated by ValidateScript).
-DestinationPathstringRequiredDestination root path. Must exist unless -CreateMissingFolders is set.
-RecurseswitchSwitch$falseProcess all sub-folders and files recursively. Without this switch only the root item is processed.
-CreateMissingFoldersswitchSwitch$falseAutomatically create missing destination directories (ShouldProcess-guarded). Missing files are still skipped.
-IncludeSystemAndHiddenswitchSwitch$falsePass -Force to Get-Item / Get-ChildItem to include hidden and system objects.
-WhatIf / -ConfirmswitchOptionalAll New-Item and Set-Acl calls are ShouldProcess-guarded.

Execution Flow

START Validate & ensure DestinationPath exists → continue | missing + -CreateMissingFolders → ShouldProcess → New-Item Directory missing + no switch → throw "Zielpfad existiert nicht. Verwenden Sie -CreateMissingFolders." Collect source items -Recurse: Get-Item + Get-ChildItem -Recurse | else: Get-Item root only | -IncludeSystemAndHidden: -Force foreach $sourceItem in $allItems | Write-Progress Compute relative path → destItemPath PSIsContainer (dir): dest missing + -CreateMissingFolders → ShouldProcess → New-Item dir PSIsContainer (dir): dest missing + no switch → Write-Warning + skip (continue) NOT container (file): dest file missing → Write-Warning + skip (continue) Get-Acl from source → ShouldProcess → Set-Acl to dest Get-Acl / Set-Acl error → Write-Warning + continue (no abort) Write-Progress Completed Write-Host "Abgeschlossen. $total Elemente verarbeitet." DONE

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