V
V
Vadim Choporov2017-01-03 12:07:51
PowerShell
Vadim Choporov, 2017-01-03 12:07:51

Is it possible to use PS to give access to files by type?

Good afternoon.
There is a file washer, which is a DFS ball. Several organizations are collected there, each in its own folder. Access to each folder of the organization is available only to employees of this organization, and the directors have rights to all organizations (well, admins, of course))). 1 of the organizations has closed, the folder is still hanging like a dead weight. Some of the designers moved to neighboring folder organizations, and lost access to the old layouts in the previous folder. Now the question arose that Korelovskie (.cdr) files are needed - but access to all folders cannot be given (budgets, etc. are not their business). Where, specifically, what lies difficult to answer - so I think, is it possible to give access to all files with the .cdr extension? They can see the content list - let them look for where their files are.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2017-01-03
@tolstyiii

well, to a first approximation, it could look something like this:
foreach ($file in (get-childitem c:\test\* -Include *.cdr -Recurse))
{
$file
$Acl = Get-Acl $file
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("username","FullControl","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl -path $file -aclobject $Acl -WhatIf
}
at the end of the script is -whatif . it needs to be removed after making sure the script can work as it should. after disabling -whatif, test on a test set before changing access to working files.
but you can not delete / move everything except the cdr files (the organization that owned the folder closed the same) and give them full access to the rest for a week. bang everything in a week?
and further. they will have access to all cdr files, but what about the folders in which cdr files are located?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question