We help IT Professionals succeed at work.

Powershell : Question

Parity123
Parity123 asked
on
Hello experts,

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.

Please assist.
Comment
Watch Question

Senior Network Consultant / Engineer
Commented:
You need to use the same user to the run the task as you used to export the credentials. The password is encrypted using the user that runs the export command. So only the same user will be able to use it.
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Best solution