I am trying to create an application that puts variables in a file (minedown.conf) using tee-object, but every time it goes to add something to the file, it overwrites it. I use
$account = Read-Host "Enter your Account SID number" "account = $account" | Tee-Object -FilePath c:\minedown\minedown.conf $token = Read-Host "Enter your Authority Token" "token = $token" | Tee-Object -FilePath c:\minedown\minedown.conf $from = Read-Host "Enter your Twilio number" "from - $from" | Tee-Object -FilePath c:\minedown\minedown.conf
I try to make each of them a separate line.
Tee-Objectis not the cmdlet you are looking for try Set-contentand Add-Content.
Tee-Object
Set-content
Add-Content
$account = Read-Host "Enter your Account SID number" "account = $account" | Set-content -Path c:\minedown\minedown.conf $token = Read-Host "Enter your Authority Token" "token = $token" | Add-Content -Path c:\minedown\minedown.conf $from = Read-Host "Enter your Twilio number" "from - $from" | Add-Content -Path c:\minedown\minedown.conf
The goal Tee-Objectis to really act like a “T” in the pipe sequence to send data from input to output and to a file or variable (to debug the channel sequence for Exemple).
PowerShell 3.0, Tee-Object -Append.
, Tee 2 . Linux . Powershell , , , Append. , .
Linux , ( ). , , ( ) , , . , - :
Write-Output "from - $from" | %{write-host $_ -ForegroundColor Blue; out-file -filepath c:\minedown\minedown.conf -inputobject $_ -append}