call icacls on powershell script failed with user variables

Hello,

I try to execute this powershell script :
$Domain="test"
$User="dba"
$UD = $Domain +"\"+ $User
Invoke-Item "icacls.exe c:\test\ /T /C /grant '%UD:(OI)(CI)F'

This message is returned :
$U: No mapping between account names and security IDs was done.

How can I resolve this problem?

Thanks

bibi
bibi92Asked:
Who is Participating?
 
XaelianConnect With a Mentor Commented:
Hi try this:

$Domain="test"
$User="dba"
$UD = $Domain +"\"+ $User
icacls.exe c:\test\ /T /C /grant ($UD+':(OI)(CI)F')
0
 
XaelianCommented:
can you try the following?

$Domain="test"
$User="dba"
$UD = $Domain +"\"+ $User
icacls.exe c:\test\ /T /C /grant '$UD:(OI)(CI)F'

You used %UD this won't work :).
0
 
bibi92Author Commented:
I have try your command :
$UD: No mapping between account names and security IDs was done.
Successfully processed 0 files; Failed processing 1 files

Thanks

bibi
0
 
bibi92Author Commented:
thanks

bibi
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.