Powershell Encrypt password RRS feed

  • Question

  • Hello

         I have use https://gallery.technet.microsoft.com/scriptcenter/Encrypt-Password-and-use-dd07f253/view/Discussions#content

         to encrypt password and connect to office 365 successful , 

       1. How to Migrate script to another server ? when I copy all script to another computer and running it then show error

       2. How to decrypt password after encrypt the same computer ? and another computer ?

    Import-Module MSOnline
    $Username = "admin@test.onmicrosoft.com"
    $Password = get-content "C:\securepassword.txt" | ConvertTo-SecureString
    #$credential = New-Object System.Management.Automation.PSCredential $Username,$Password
    $credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $Username,$Password
    Connect-MsolService -Credential $credential

    Best Regards,


    • Moved by Bill_Stewart Wednesday, February 14, 2018 7:34 PM This is not a support forum for gallery scripts
    Wednesday, January 3, 2018 12:58 PM

All replies

  • Encrypted passwords cannot be shared between accounts.

    For Gallery scripts post your question in the Gallery: https://gallery.technet.microsoft.com/scriptcenter/Encrypt-Password-and-use-dd07f253/view/Discussions#content


    Wednesday, January 3, 2018 3:29 PM
  • You could map the "C:\securepassword.txt"  to a repo i.e. a place that is common on all server, 

    for me e.g.

    $password = Get-content "$env:userprofile\Dropbox\pass.txt" | ConvertTo-SecureString

    What i know, i ran:

    read-host -assecurestring | convertfrom-securestring | out-file "$env:userprofile\Dropbox\sample.txt" 

    then I compared the hash of both files, totally different, however you can use both to login to msolservice.


    david.lay7@tafensw.net.au netadminstrator@hotmail.com

    Friday, January 5, 2018 2:51 AM
  • Thanks All Support , I thing I will gen new file when running it on another computer
    Friday, January 5, 2018 4:42 PM