Batch files are generally executed by CMD.EXE; PowershellPowerShell is executeexecuted by PowerShell.exe. The two are different, and scripts that work in one will not work in the other. The code that you've pasted into your question is unquestionably PowerShell, not Batchbatch. You might find it useful to look at some of Microsoft's PowerShell basics.