I have the following script:
get-credential | export-clixml c:\temp\temp1.xml
$cred = import-clixml -path c:\temp\temp1.xml
get-addomain -identity test.local -Cred $cred
the above script works if I run it from a command prompt and fails when I run this in a scheduled task. I get access denied, must be the creds are not getting passed.