<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A problem when running A PowerShell script in Microsoft task schedular in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116512#M4779</link>
    <description>&lt;P&gt;Hello Andrew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ehab&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2016 18:32:03 GMT</pubDate>
    <dc:creator>ehabshukry</dc:creator>
    <dc:date>2016-03-01T18:32:03Z</dc:date>
    <item>
      <title>A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116508#M4776</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 &amp;nbsp;from the powershell command line. The same script will fail if I run it in the Micsosoft task schedular of Win 2012R2 using &lt;STRONG&gt;system&lt;/STRONG&gt; 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 &amp;nbsp;forever. &amp;nbsp;I added a couple of commands to write text to a log file to &amp;nbsp;know where the script stops at, and I found it stops at &amp;nbsp;"&lt;STRONG&gt;connect-nacontroller filer_ip&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;&amp;nbsp;-Credential &amp;nbsp;$cred&lt;/STRONG&gt;"!&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Please note that&lt;STRONG&gt;&amp;nbsp;system&lt;/STRONG&gt; account has full right on the machine. Here's the script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran the following commands to store the secure pass in a file:&lt;/P&gt;&lt;P&gt;$secureString = Read-Host -AsSecureString "Enter password to convert to secure string"&lt;/P&gt;&lt;P&gt;$secureString | ConvertFrom-SecureString | Out-File -PSPath "C:\ps.txt"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------- script start from here&lt;BR /&gt;$secureString = Get-Content -PSPath "C:\ps.txt" | ConvertTo-SecureString&lt;BR /&gt;$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "username",$secureString&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;connect-nacontroller filer_ip&amp;nbsp;-Credential &amp;nbsp;$cred&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set-NaSnapvault -PrimarySystem primary_filer -PrimaryPath /vol/vol_name -SecondaryPath /vol/vol_name -MaxTransferRate 4mb&lt;/P&gt;&lt;P&gt;exit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have any idea what's going on or how to fix it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Appreciate your quick help!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 21:55:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116508#M4776</guid>
      <dc:creator>ehabshukry</dc:creator>
      <dc:date>2025-06-04T21:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116510#M4777</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secure strings are encrypted on a per-user basis. &amp;nbsp;If you encrypt it, then no other user can decrypt it. &amp;nbsp;Try running the scheduled task as your user and see if it succeeds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 18:17:14 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116510#M4777</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-03-01T18:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116511#M4778</link>
      <description>&lt;P&gt;Thanks a lot for the v. quick response, I'll give it a try.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 18:22:28 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116511#M4778</guid>
      <dc:creator>ehabshukry</dc:creator>
      <dc:date>2016-03-01T18:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116512#M4779</link>
      <description>&lt;P&gt;Hello Andrew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ehab&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 18:32:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116512#M4779</guid>
      <dc:creator>ehabshukry</dc:creator>
      <dc:date>2016-03-01T18:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116585#M4783</link>
      <description>&lt;P&gt;Could you try using Get-Credential instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$cred = Get-Credential&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It'll prompt for the login and password - use the service account and password - see if that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can check out this link concenring saving it to a file and reusing the credentials&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.adminarsenal.com/admin-arsenal-blog/secure-password-with-powershell-encrypting-credentials-part-1/" target="_blank"&gt;http://www.adminarsenal.com/admin-arsenal-blog/secure-password-with-powershell-encrypting-credentials-part-1/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 20:17:34 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116585#M4783</guid>
      <dc:creator>JohnChampion</dc:creator>
      <dc:date>2016-03-02T20:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116613#M4784</link>
      <description>&lt;P&gt;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. &lt;A href="http://windowsitpro.com/development/save-password-securely-use-powershell" target="_self"&gt;This page&lt;/A&gt; has several methods of saving credentails (including showing how to read in a plaintext password and convert it into a PSCredential object).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might try using a service account for executing the scheduled task. &amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 14:34:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116613#M4784</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-03-03T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116638#M4785</link>
      <description>&lt;P&gt;Thanks Andrew. I used Psexec -s -i powershell.exe. &amp;nbsp;Ran&amp;nbsp;get-securestring and save it to a txt file. &amp;nbsp;Then I used the task schedular to run the script unders system account, and it went successfully.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 18:41:58 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116638#M4785</guid>
      <dc:creator>ehabshukry</dc:creator>
      <dc:date>2016-03-03T18:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: A problem when running A PowerShell script in Microsoft task schedular</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116639#M4786</link>
      <description>&lt;P&gt;Thanks John for the article.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 18:43:54 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/A-problem-when-running-A-PowerShell-script-in-Microsoft-task-schedular/m-p/116639#M4786</guid>
      <dc:creator>ehabshukry</dc:creator>
      <dc:date>2016-03-03T18:43:54Z</dc:date>
    </item>
  </channel>
</rss>

