I am trying to figure out as why these commands are not running via script. But when I run this manually it's working.
$value = Get-Content c:\info.txt | select-string Id | Foreach-Object { $_.ToString().split(':')[1] -replace '\s','' }
Write-Host "$value" >> c:\list.txt
I have tried to redirect out using >> but still there is no information gets updated in variable $value
Get-Content c:\info.txt | select-string Id | Foreach-Object { $_.ToString().split(':')[1] -replace '\s','' } >> $value
Write-Host "$value" >> c:\list.txt