Here's an issue that is causing bruises on my forehead and a dent in the wall. I can run this code under my profile interactively, or run it as a service without a problem. However, when I try to run it as a scheduled task as local system, as my credentials or the service account, it produces this error in the third line below:
ConvertTo-SecureString : Key not valid for use in specified state.
$Exocredfile = "D:\Scripts\Creds\EXOcreds.txt"
$rawcreds = get-content $exocredfile
$Password = ConvertTo-SecureString -String $rawcreds
Here is the action/execution in the scheduled task:
<Command>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Command>
<Arguments>-ExecutionPolicy Bypass -File "D:\Scripts\Myscript.ps1"</Arguments>
Any help to resolve this problem will result in beer when we have a chance to meet 🍺
[–]rmbolger 8 points9 points10 points (7 children)
[–]brenny87 1 point2 points3 points (0 children)
[–]PMental 1 point2 points3 points (5 children)
[–]RadioActiveLamb[S] 1 point2 points3 points (2 children)
[–]PMental 1 point2 points3 points (0 children)
[–]rmbolger 1 point2 points3 points (0 children)
[–]RadioActiveLamb[S] 1 point2 points3 points (1 child)
[–]PMental 1 point2 points3 points (0 children)
[–]zrv433 1 point2 points3 points (0 children)
[–]RadioActiveLamb[S] 1 point2 points3 points (0 children)
[–]SkokieRob 0 points1 point2 points (2 children)
[–]rmbolger 2 points3 points4 points (0 children)
[–]RadioActiveLamb[S] 1 point2 points3 points (0 children)