title: How to Apply Encrypt/Decrypt in Powershell?
body: <p>Im using in PS the next command:</p>
  
  <pre><code>"Password" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString
  </code></pre>
  
  <p>This generate a Key that im saving as "Key.txt" file</p>
  
  <p>Now i want to decrypt that password using this:</p>
  
  <pre><code>$password = Get-Content password.txt (or just copy-pasting the key)
  $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,($password | ConvertTo-SecureString)
  </code></pre>
  
  <p>BUT...</p>
  
  <p>how i supose to add that to this...</p>
  
  <pre><code>$EmailFrom = "MyMail@gmail.com"
  $EmailTo = "MayMail@gmail.com" 
  $Subject = "Test" 
  $Body = "this is a Test" 
  $SMTPServer = "smtp.gmail.com" 
  $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) 
  $SMTPClient.EnableSsl = $true 
  $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("My_USer", "My_Password"); 
  $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
  </code></pre>
  
  <p>I want to add it as My_Password, of course i should add a variable $password that comes from the Key.txt file for example, but then...? </p>