M
M
Mad_runner2019-11-29 09:33:15
PowerShell
Mad_runner, 2019-11-29 09:33:15

How to use Set-acl in a loop?

I need to copy the permissions of one directory to several others, all directories are in one place.
I am in powershell=0. At the moment, this is what I have:
//save permissions to a variable.
$acl = Get-acl 'd:\obm\Lastname Firstname'
// that's all.
And how to apply Set-acl further in a cycle (for example foreach) that would go through all the directories in 'd:\obm' and assign permissions from $acl.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Somewhere Intech, 2019-11-29
@Jonatan_ice

Get-ChildItem d:\obm -Recurse -Directory | forEach { set-acl -path $_.FullName -aclObj $acl }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question