Skip to content

Instantly share code, notes, and snippets.

@giseongeom
Created July 9, 2019 09:47
Show Gist options
  • Select an option

  • Save giseongeom/162679f1b71124b50aed03301c877cbf to your computer and use it in GitHub Desktop.

Select an option

Save giseongeom/162679f1b71124b50aed03301c877cbf to your computer and use it in GitHub Desktop.
Create PSCredential object using cleartext
function New-PSCredential([string]$User, [string]$Pass) {
$username = $User
$password = ConvertTo-SecureString $Pass -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList ($username, $password)
return $psCred
}
@giseongeom
Copy link
Author

  • Usage
$cred = New-PSCredential -User '1a01234567898' -Pass 'password'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment