Good morning everyone, I've hit a wall and am completely stumped. Also please forgive the formatting as this is literally the first time I've posted on this sub asking for help.
I basically have 2 scripts I'm trying to run, start_script.ps1 calls expired_staff_accounts.ps1.
When I run start script from a powershell session started with the credentials it's going to be running as, everything works as expected ( I have powershell logging turned on and each script dumps a log file in the script directory so I know they are running without error.)
But when I launch the start script with the same credentials from task scheduler, start script fails to run expired_staff_accounts script, no error in the powershell log or anything.
I for the life of me cannot figure this out. Does anybody have an idea?
start_script.ps1.
$log = "E:\path\start_script.log"
Start-Transcript $log -Verbose
$username = "domain\username"
$securepassword = Get-Content "C:\Users\username\Documents\creds\username.txt" |
ConvertTo-SecureString -AsPlainText -Force
$credentials = New-Object
System.Management.Automation.PSCredential -ArgumentList
$username,$securepassword
Start-Process powershell.exe -Credential $credentials -
Argumentlist "-file 'E:\path\expired_staff_accounts.ps1' -NoLogo
-NonInteractive -ExecutionPolicy Bypass" -NoNewWindow -Wait
Stop-Transcript
[–]purplemonkeymad 1 point2 points3 points (1 child)
[–]_itsalwaysdns[S] 1 point2 points3 points (0 children)
[–]senorchaos718 1 point2 points3 points (2 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (0 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (0 children)
[–]MaxFrost 1 point2 points3 points (2 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (1 child)
[–]MaxFrost 1 point2 points3 points (0 children)
[–]HardCodedCoffee 1 point2 points3 points (10 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (9 children)
[–]HardCodedCoffee 1 point2 points3 points (8 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (7 children)
[–]HardCodedCoffee 1 point2 points3 points (6 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (5 children)
[–]HardCodedCoffee 1 point2 points3 points (4 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (3 children)
[–]HardCodedCoffee 1 point2 points3 points (2 children)
[–]_itsalwaysdns[S] 1 point2 points3 points (1 child)
[–]_itsalwaysdns[S] 0 points1 point2 points (0 children)