I'm attempting to run sfc.exe /scannow on a remote computer using PowerShell's Start-Process, but I'm unable to confirm whether the process starts on the remote machine. When I check for any sfc processes using Get-Process sfc, I don't see any processes running. How can I effectively start sfc.exe /scannow on a remote machine using Start-Process?
Here's the PowerShell code I'm using:
$remoteComputer = "RemoteComputerName"
$scriptBlock = {
Start-Process -FilePath "C:\windows\system32\sfc.exe" -ArgumentList "/scannow" -NoNewWindow -Wait
}
Invoke-Command -ComputerName $remoteComputer -ScriptBlock $scriptBlock
Update: If I start it like this it works, but do I do it with Start-Process?
Invoke-Command -ComputerName $remoteComputer -ScriptBlock {& $(${env:Windir} + "\System32\SFC.EXE") "/scannow"}
Start-Process? It sounds like simply runningsfc.exe /scannowdirectly might solve your problem (or at least reveal why the process dies too quickly)Start-Processwill make a difference here. Try changing it to justsfc.exe /scannow, run it and see what happens :)Start-Processthen? What change in behavior are you hoping to get from usingStart-Processinstead?