Assume I have a custom PowerShell Cmdlet that exports data and encrypts it using a password.
[Cmdlet(VerbsData.Export, \"SampleData\")]
public class ExportSample
You can find in this answer a way to crypt with the computer password (works on safe machines).
Using @Christian response you can put the password to the disk like this :
PS > $cred.Password | ConvertFrom-SecureString | Set-Content c:\temp\password.txt
And retreive it with :
$password = Get-Content c:\temp\password.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PsCredential "UserName",$password