How do I specify chmod 744 in Powershell?

I know that I can use icacls to specify the permission on the file, and from What is the equivalent of chmod 777?, I can use

icacls myfile.txt /grant Everyone:F

But how do I set an equivalent for chmod 744? I think I can use /grant:____:R for just read access, but I'm not sure how to specify the owners and the group permissions as simply as with chmod. When I try this:

icacls myfile.txt /grant Owner:F Group:R Everyone:R

I receive an error, "No mapping between account names and security IDs was done." I'm probably missing something obvious, any ideas?

When I try:

icacls myfile.txt /grant Administrator:F /grant:r Users:R

I take a look at the file in Explorer and it has given Administrator "Special Permissions" (rather than Full Control) and gives Users "Read & execute, Read, and Special Permissions."

1

1 Answer

Give this a shot and see if this does what you're trying to accomplish. I always run these explicitly so one for setting the Owner, one for Full Control, one for Read-only, and one for Read and Execute.

This way you can do it for a specific file and for a specific user or group where applicable. Just plug in your file names, etc.

Sample ICACLS commands to set owner, grant full control, read-only, and read plus execute access(You may need to run the command prompt as administrator with these commands)

::Set Owner of a specific file
ICACLS "D:\test\test.txt" /setowner "administrator"
::Grant Full Control
ICACLS "D:\test\test.txt" /grant:r "administrator:(F)" /C
::Grant Read and Execute Access of a specific file
ICACLS "D:\test\test.txt" /grant:r "users:(RX)" /C
::Grant Read-only Access of a specific file
ICACLS "D:\test\test.txt" /grant:r "users:(R)" /C
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like