Below is a quick Powershell command I use to convert passwords to secure strings and output to an XML file, I can encrypt that XML file locally on the machine where any scripts need to run from, and call it in another Powershell script.
$secpasswd = ConvertTo-SecureString "VMware1!" -AsPlainText -Force #The logic used here between the brackets is Username,Password, where we call our previous variable $mycreds = New-Object System.Management.Automation.PSCredential ("administrator", $secpasswd) $mycreds | export-clixml -path c:\temp\password.xml
It’s quick and easy to use, there will be other ways that may work better for you, if so, drop them in the comments.