Permission Issues running sfc,chkdsk,dism as job in script??

So I’m trying to create a script to run sfc,chkdsk, and dism as a job on the computer. It’s intended to be run on a computer that would be signed in as a standard user so that I can run this at the end of the day when I need to and check the reports after

I think I’ve got the majority of the script in place already but running into issues when it gets to runing the actual utilities. It tells me that admin privelleges are needed please run in an elevated prompt.

At the time of testing I was signed in as a local admin on the computer and simply testing out the commands in an admin session of PS so there should be no permission issues. If I remote the -credential parameter from the start-job cmd then the script runs (as I would expect, given that Im signed in as admin).

Left the commands attached, open to any help/suggestions/opinions. End goal is to be able to run this by double clicking and forgetting about it until the next day, I don’t want to input passwords at all and would like for it to be run by a non-admin computer account.

######## *omitted $user and $pass lines
$Cred= New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
$Path= 'C:\JobLogs'
$Date= get-date -format "dd MM yyyy mm ss"
$LogFile= "C:\JobLogs\ResultsFrom$date.txt"
start-job -name DiskCheck -ScriptBlock { CHKDSK C: } -Credential $cred
start-job -name SFC -ScriptBlock { sfc /scannow } -Credential $cred
start-job -name DISM -ScriptBlock { DISM /Online /Cleanup-Image /RestoreHealth } -Credential $cred
if (test-path $path) { write-host "`$Path was found, exporting logs to $Path" } else { new-item C:\JobLogs -itemtype directory; Write-Host "$Path not found, creating $Path and exporting logs" }
wait-job -name DiskCheck,SFC,DISM | receive-job | out-file -FilePath $LogFile

Try running this and see what you get back from your test.

if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
  Write-Output "Elevated."
  Write-Output "Not elevated."

Hey @Alex, sorry for the late reply!

When I ran that immediately after my script, I get “Elevated.”

Also, when I run the job on its own, manually like below, I get no issues, and can retrieve the job and view its results.

start-job -name SFC2 -ScriptBlock { sfc /scannow }


When I run it via the script and supplying the credentials to use, it responds with Error 740, Admin privs needed. Still stumped on this I cant seem to figure out where the permissions issue lie.