How To Manage File System ACLs With PowerShell

I have tried How To Manage File System ACLs With PowerShell
link http://www.tomsitpro.com/articles/powershell-manage-file-system-acl,2-837.html

I am unable to get the last part to run any help will be appreciated
http://www.tomsitpro.com/articles/powershell-manage-file-system-acl,2-837.html

First part
((Get-Item c:\test).GetAccessControl('Access')).Access

Second part
[PS] C:\Windows\system32>((Get-ChildItem c:\test -Directory).GetAccessControl('Access')).Access
Get-ChildItem : A parameter cannot be found that matches parameter name 'Directory'.
At line:1 char:35
+ ((Get-ChildItem c:\test -Directory <<<< ).GetAccessControl('Access')).Access
    + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Member_2_6474242Senior Systems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
You're still running PowerShell 2.0, by now nearly nine years old.
Instead of "Get-ChildItem C:Homefolders -Directory", you can use
$HomeFolders = Get-ChildItem C:Homefolders | Where-Object {$_.PsIsContainer}

Open in new window

Or, in your example,
((Get-ChildItem c:\test | Where-Object {$_.PsIsContainer}).GetAccessControl('Access')).Access

Open in new window


Or upgrade PowerShell, if possible:
Windows Management Framework 5.1
https://www.microsoft.com/en-us/download/details.aspx?id=54616

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Actually, I think I mistook your use of a parameter that is unsupported as if it was part of the directory path.

If not, then you need to wrap your directory path in quotes.

Second part
[PS] C:\Windows\system32>((Get-ChildItem c:\test -Directory).GetAccessControl('Access')).Access
Get-ChildItem : A parameter cannot be found that matches parameter name 'Directory'.
At line:1 char:35
+ ((Get-ChildItem c:\test -Directory <<<< ).GetAccessControl('Access')).Access
    + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Becomes:

((Get-ChildItem "c:\test -Directory").GetAccessControl('Access')).Access

Open in new window


Yeah my mistake, look at the answer above mine, quick read-through I did I didn't realize you were running into an issue of trying to run newer Powershell commands in an older PS environment, the above answer answers this succinctly.
Member_2_6474242Senior Systems AdministratorAuthor Commented:
what i want to achieve is to set permissions to multiple folders on a shared network drive. The drive has folders with the id of users which is the logon name. Is there any working script that can get this done
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
This expert suggested creating a Gigs project.
I'd propose this since it requires more than just simple scripting.
Member_2_6474242Senior Systems AdministratorAuthor Commented:
how can i  do it. What is a Gigs project?
Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
A Gigs project is a paid project. where you can hire a freelancer to do the job.
It's located at the top of the page under "Products/Gigs"
Member_2_6474242Senior Systems AdministratorAuthor Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.