Command:
(Get-Credential).Password | ConvertFrom-SecureString | Out-File “C:\Temp\ABC_A1000001_PW.txt”

Script:

$username = “ABC\A1000001”

$password = Get-Content ‘\\server.domain.xyz\Scripts\Migration\ABC_A1000001_PW.txt’ | ConvertTo-SecureString

$cred = new-object -typename System.Management.Automation.PSCredential `

-argumentlist $username, $password