1

Currently I am writing a powershell script to automate some security measures and I have run into a small problem.

icacls myDirectory /inheritance:r /grant:r 'Administrators:F' $myGroup + ':F'

will fail as $myGroup gets tacked onto the icacls call and fails to properly add permissions to both groups. This is on Windows 7 and from the context of powershell.

1 Answer 1

3

The parser sees $myGroup + ':F' as three individual arguments. You can use either:

"${myGroup}:F"

or

($myGroup + ':F')

to provide this info to the parser as one argument.

Sign up to request clarification or add additional context in comments.

3 Comments

The second one works, the first one fails. Once you make that change I will accept this as the answer
Looks like : can be a legal part of a variable name, so you have to delineate the variable name part of the string using { and }.
Hmm, can't put : in a variable name AFAICT. Wonder why then the parser can't figure this out and not requires the curly braces?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.