Encrypt Password and use it in Powershell Script

As Technet Gallery is retiring so moving the code to Git Hub. (click below link, creating first link to my blog for those who are unfamiliar with github)Encrypt Password and use it in Powershell ScriptHi Readers,Today I am sharing a way to encrypt the password & using it in power

 
 
 
 
 
3.5 Star
(22)
Add to favorites
3/30/2020
E-mail Twitter del.icio.us Digg Facebook
  • Thanks for the solution
    1 Posts | Last post August 03, 2018
    • Glad I came across this encryption script
  • Add -assecurestring parameter
    2 Posts | Last post August 24, 2017
    • Hello Sukhija.
      
      This is more a suggestion than a question: Add the parameter -assecurestring to the Read-Host Cmdlet
      
      Regards.
    • I just noticed the script writes a message with the password right after receiving it, which makes the -assecurestring parameter senseless. Perhaps having a version for paranoids?
      
      Regards.
  • Why have it complicated.
    4 Posts | Last post November 10, 2015
    • Hi Sukhija.
      
      Any reason why you do not use code like 
      
      $Creds = Get-credentials
      $Creds.Password | ConvertFrom-SecureString $secure | out-file .\securepassword.txt
      
      And when you need it you just
      $creds = Get-content .\Securepassword.txt | ConvertTo-Securestring
      
    • Oh please ignore the $Secure after Convertfrom-Securestring i forgot to remove it after copy/pasting your code.
    • Reason is I want to embed it in script & don't want any other text files in the path.
      You can use it the way you want.
    • If you are running from same system & same user id than you will be able to do it..
  • Can that encryption number be used in another script to modify?
    1 Posts | Last post November 06, 2015
    • Hi Sukhija,
      
      When i am using the random encryption number generated in the text file. Its just that i am not able to view the plain password string. But what if i use the same enrcyption number in another script to modify something. WIll i be able to do it? If its a domain admin or something, wont that be insecure enough? Let me know please.
  • Use credential to open RDP Session
    3 Posts | Last post July 05, 2014
    • Hi ! 
      Thanks a lot for your sharing.
      
      I'd like to use your code with this function =>
      http://gallery.technet.microsoft.com/scriptcenter/Connect-Mstsc-Open-RDP-2064b10b/view/Discussions#content
      
      
      Please could you help to accomplish it ?
    • I answer to myself:
      
      $credential = Get-Credential
      $credential.GetNetworkCredential().Password 
    • Good to hear..