My company is in the process of reorganizing all windows scheduler tasks that utilize PowerShell scripts. For security reasons, we are no longer allowed to use an admin domain account to call the scheduler tasks directly. However, some scripts require admin domain rights to perform their tasks.
The proposed solution is to have the Task Scheduler call a PowerShell script that accesses encrypted credentials for an admin account and uses these credentials to invoke the required script.
Here is the method I attempted to use for invoking another script:
$arguments = "-NoProfile -ExecutionPolicy Bypass -NoExit -File `"$ScriptPath`""
Start-Process -FilePath "powershell.exe" -ArgumentList $arguments -Credential $credential -NoNewWindow
Unfortunately, this approach has not been successful so far.
Is there a reliable way to schedule PowerShell tasks that require admin privileges without directly using an admin domain account? Any guidance or examples would be greatly appreciated.
Thank you!