I'm using powershell to start process as another user. To do this I'm using "Start-Process" as below.
$creds = Get-Credential -UserName $Name -Message "Please enter authorized credentials"
Start-Process `
-Credential $creds `
"C:\MyPowerfullProcess.exe" `
-RedirectStandardOutput $logOutputPath `
-RedirectStandardError $logErrorPath `
-WorkingDirectory $workingPath `
-ArgumentList $processArg
Stop-Transcript
The problem is that the $workingPath is only accessible to the user $creds and not by the user who started the .ps1 script. And The Start-Process command trough this error : "WorkingDirectory" Invalid [..] DirectoryNotFoundException
Start-Process
- CategoryInfo : InvalidOperation : (:) [Start-Process], DirectoryNotFoundException
- FullyQualifiedErrorId : DirectoryNotFoundException,Microsoft.PowerShell.Commands.StartProcessCommand