Powershell script running in a batch file
Hey all,
I have a small PS script I am trying to run in a batch file for the purpose of renaming a folder with in an applications configuration file. The end goal being that I would like to attach the batch file to the MSI I am building without having to run it seperatly.
Anyway, The batch file returns with the error: "Foreach-Object is not recognized as an internal or external command"
Here's the batch file it it's entierty, I'm hoping I just have a comma out of place or somthing:
echo off
powershell.exe -Command $username = $env:username;(get-content ${env:PROGRAMFILES(X86)}\Accumap\default.cfg)|;Foreach-Object {$_ -replace "useridfolder", "$username"}|;Set-Content ${env:PROGRAMFILES(X86)}\Accumap\default.cfg
Thanks!
Answers (1)
I believe you need a space after the pipe not a ;
powershell.exe -Command $username = $env:username;(get-content ${env:PROGRAMFILES(X86)}\Accumap\default.cfg)| Foreach-Object {$_ -replace "useridfolder", "$username"}| Set-Content ${env:PROGRAMFILES(X86)}\Accumap\default.cfg