

{"id":247,"date":"2016-06-01T09:16:14","date_gmt":"2016-05-31T23:16:14","guid":{"rendered":"https:\/\/kng.tech\/blog\/?p=247"},"modified":"2016-06-17T13:47:15","modified_gmt":"2016-06-17T03:47:15","slug":"password-encrypted-as-securestring-in-powershell","status":"publish","type":"post","link":"https:\/\/kng.tech\/blog\/password-encrypted-as-securestring-in-powershell\/","title":{"rendered":"Password encrypted as SecureString in powershell"},"content":{"rendered":"<p>Create a password file with securestring:<\/p>\n<p><code>Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath C:\\encrypted.securestring<\/code><\/p>\n<p>Use the password file to create a PSCredential<\/p>\n<p><code>$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList \"username\",(Get-Content -Path C:\\encrypted.securestring | ConvertTo-SecureString)<\/code><\/p>\n<p>Reference <a href=\"https:\/\/rcmtech.wordpress.com\/2016\/03\/03\/send-smtp-email-with-authentication-from-powershell\/\" target=\"_blank\">here<\/a>.<\/p>\n<p>I realized that this encrypted password only work on the machine which encrypting it.<br \/>\nTo have this works on a different computer(s), you would need the key and the encrypted file.<\/p>\n<div class=\"line number1 index0 alt2\" style=\"text-align: left;\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Create a password file with securestring: Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath C:\\encrypted.securestring Use the password file to create a PSCredential $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList \"username\",(Get-Content -Path C:\\encrypted.securestring | ConvertTo-SecureString) Reference here. I realized that this encrypted password only work on the machine which encrypting it. To have this works on a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[50,43,44,45],"class_list":["post-247","post","type-post","status-publish","format-standard","hentry","category-tech","tag-encrypted","tag-powershell","tag-scripting","tag-securestring"],"_links":{"self":[{"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/posts\/247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/comments?post=247"}],"version-history":[{"count":6,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/posts\/247\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/posts\/247\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/media?parent=247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/categories?post=247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kng.tech\/blog\/wp-json\/wp\/v2\/tags?post=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}