FN-GM Posted September 27, 2019 Posted September 27, 2019 (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 Edited September 27, 2019 by FN-GM
MartinByard Posted September 27, 2019 Posted September 27, 2019 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. 1
Diello Posted September 28, 2019 Posted September 28, 2019 The other method is to employ backticks around it, e.g. icacls "C:\Test\1" /grant:r [email protected]:`(OI`)`(CI`)M /T 1
FN-GM Posted September 30, 2019 Author Posted September 30, 2019 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 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now