I have the following PowerShell-Command which works perfectly fine when called from powershell directly:
Get-ChildItem -r -include 'AssemblyInfo.cs' `
| foreach-object { $a = $_.fullname; ( get-content $a ) `
| foreach-object { $_ -replace '((\[assembly:\sAssemblyVersion\(")(\d\.\d\.\d\.\d)("\)\]))', '$1[assembly:AssemblyInformationalVersion("$3-alpha")]' } `
| Out-File $_.fullname }
However, when called from cmd (our Buildservers-Process runs in cmd) it does not raise an error but it also does't replace the string as expected (it can be reproduced from any cmd-window):
PowerShell -Command "(Get-ChildItem -r -include 'AssemblyInfo.cs') | foreach-object { $a = $_.fullname; ( get-content $a ) | foreach-object { $_ -replace '((\[assembly:\sAssemblyVersion\(")(\d\.\d\.\d\.\d)("\)\]))', '$1[assembly:AssemblyInformationalVersion("$3-alpha")]' } | Out-File $_.fullname }"
I tried around with escaping quotation-marks and commands using and&` but it didn't help.
What am i missing out?