title: powershell Write-Output with >> to a file.txt -Append
body: <p>I am creating a script and want to both use Write-Host and Write-Output
  As I work I want a backup of information I pull from AD to also become attached to a .txt file. 
  This is more of a backup in case I miss a piece of information and need to go back and recreate a ticket. Anyways I have a sample of my script, form what I can tell it should be working. If someone with a bit more experience can take a look or point me in the right direction I would appreciate it. If I need to add any more of the script I can provide this.  Thanks in Advance.</p>
  
  <pre><code>Import-Module activedirectory
  $object = Get-ADUser $sid -Properties * | Select-Object EmailAddress
  Write-Host Email: $object.EmailAddress
  Write-Output ("Email: $object.EmailAddress") &gt;&gt; C:\psoutput\psoutput.txt -Append
  </code></pre>
  
  <p>This will create the .txt file of course but is also add other information such as:</p>
  
  <pre class="lang-none prettyprint-override"><code>Email: @{GivenName=myfirstname; Surname=mylastname; SamAccountName=myid; DisplayName=lastname, firstname - Contingent Worker; City=; EmailAddress=myemailaddress@mywork.com; EmployeeID=; Enabled=True; OfficePhone=; MobilePhone=(555) 555-5555; LockedOut=False; LockOutTime=0; AccountExpirationDate=05/09/2020 00:00:00; PasswordExpired=False; PasswordLastSet=12/03/2019 12:16:37}.EmailAddress
  -Append
  </code></pre>
  
  <p>I am looking to have the output like the following...</p>
  
  <pre class="lang-none prettyprint-override"><code>name: username
  email: user email address
  phone: user phone number
  etc...
  </code></pre>
  
  <p>All general information from Active Directory</p>
  
  <p>Thanks again for the suggestions</p>