Jump to content

Recommended Posts

Posted (edited)

Hello,

 

I am trying to run the following command in a Powershel script. This is to grant a user modify rights onto a folder. I am doing it this was as it cannot be done in Powershel code on a single line.

 

icacls "C:\Test\1" /grant:r [email protected]:(OI)(CI)M /T

 

Powershell is kicking up a fuss with the (OI) bit. See attached. It works ok in the command prompt.

 

Can someone help with getting this working please?

 

Thanks

Capture.PNG

Edited by FN-GM
Posted

try using:

 

icacls "C:\Test\1" --% /grant:r [email protected]:(OI)(CI)M /T

 

the --% tells powershell to interpret the rest of the line as a basic text string, and not to try and process any of it as cmdlets. This is how we use icacls in powershell scripts when we have to.

  • Thanks 1
Posted

Thanks to both of you for the replies.

 

In the end I sued the below. The only reason was it was easier to read / interpret. It worked a treat.

 

Cheers

 

 

The other method is to employ backticks around it, e.g.

 

icacls "C:\Test\1" /grant:r [email protected]:`(OI`)`(CI`)M /T

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...