I want to use Powershell toolkit 3.3 to throttle SnapVault relation at a specific time of the day. I can run the script successfully from the powershell command line. The same script will fail if I run it in the Micsosoft task schedular of Win 2012R2 using system account. I've tried to right click on the script in the task scheduler, and then run it but the script stays in "running" state forever. I added a couple of commands to write text to a log file to know where the script stops at, and I found it stops at "connect-nacontroller filer_ip -Credential $cred"! Please note that system account has full right on the machine. Here's the script:
I ran the following commands to store the secure pass in a file:
$secureString = Read-Host -AsSecureString "Enter password to convert to secure string"
Is there any other way I can encrypt the password and then run the script under anohter account? The problem I'm using a card to authenticate my account to the system, so my account couldn't be used to run the script in the task schedular. Your thoughts will be highly appreciated.
I believe that all of the methods which store the password securely are tied specifically to the user which creates the secured password/credentail object. This page has several methods of saving credentails (including showing how to read in a plaintext password and convert it into a PSCredential object).
You might try using a service account for executing the scheduled task. Open a PowerShell prompt as the service account, create the credential object and store it securely, then when it's executed by Scheduler it won't have an issue accessing the credential.
If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.