I have a problem replacing an entire line in an ini file, it just adds my result to the same line.
Here is the ini file:
[environment] APP_USER=Domain\User1
I just want to replace APP_USER = Domain \ User1, for example, APP_USER = Domain \ User2.
Here is my code:
$USER = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name (Get-Content D:\Test\test.ini) | ForEach-Object { $_ -replace "APP_USER=" , "APP_USER=$user" } | Set-Content D:\Test\test.ini
I get this result when I use the code above:
[environment] APP_USER=Domain\User2Domain\User1
Help would be greatly appreciated.
// Regard PMS
user2400659
source share