Password in Powershell Script #003

Password in Powershell Script #003

### Step 1: Creating Securestring
$password = Read-Host -AsSecureString
$password | ConvertFrom-SecureString | Out-File .\Desktop\password.txt

### Step 2: Using Securestring in Scripts
$username = "Administrator"
$password = Get-Content .\Desktop\password.txt | ConvertTo-SecureString
$credentials = New-Object System.Management.Automation.PSCredential (“$username”, $password)

You may also like...