I am guessing you are trying to pass "Y(es)" to any possible prompts?
CMD shell and PowerShell are two different shells. What you are trying to do is use the CMD shell syntax for Powershell and therefore running into trouble
$_ is used when you are iterating through an array coming from pipeline, so there must be something other than what you have shared here. I will give you an example.
Assume I have 2 files in c:\temp\:
c:\temp\a.txt
c:\temp\b.txt
and I want to grant them permissions and not to be prompted.
"c:\temp\a.txt","c:\temp\b.txt" | foreach-object {
ECHO Y|cacls $_ /G ADMINISTRATORS:F
echo Y|cacls $_ /G SYSTEM:F /T /E
}
This is equivalent to the following
ECHO Y|cacls c:\temp\a.txt /G ADMINISTRATORS:F
echo Y|cacls c:\temp\a.txt /G SYSTEM:F /T /E
ECHO Y|cacls c:\temp\b.txt /G ADMINISTRATORS:F
echo Y|cacls c:\temp\b.txt /G SYSTEM:F /T /E
$_ is being replaced withing foreach-object by what is coming down from pipeline, which is pretty much imitating CMD shell command that would work.