Can anyone explain to me why I can write 'ECHO Y|' in the Powershell command line but not if I implement it in a script?

These variables are taken from a .csv file. When I used the command line I did not use the variables.

```
ECHO Y|cacls $_."Serverdisc" /G ADMINISTRATORS:F
 cacls $_."Serverdisc" /G $_."Username":C /T /E
 cacls $_."Serverdisc" /G SYSTEM:F /T /E

```
['https://Stackoverflow.com/questions/20402662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2564636/']
I will add to Adil H.'s comments and say that using cacls is depreciated. You should instead be using **icacls**. icacls has a parameter /Q (Quiet) which will suppress all the confirmation messages for you, and you will not have to use `ECHO Y|` in your code.

(assuming you have the rest of your script in order(see Adil H.'s post)) Your script block would change to this:

```
icacls $_."Serverdisc" /Q /Grant ADMINISTRATORS:F
icacls $_."Serverdisc" /Q /Grant $_."Username":C /T
icacls $_."Serverdisc" /Q /Grant SYSTEM:F /T

```
It's probably because the pipeline function of powershell is different from the cmd prompt

If you use `cmd /c echo Y| cacls ....`
it will work.