PowerShell Start-Process Credential error. In some conditions, you will get an error
The system cannot find the file specified
Or
The Directory name is invalid
The error occurs only if the parameter Credential is set.
Start-Process Credential errors
Start-Process The file cannot find the file. Even with the full path specified, another error occurs: The Directory name is invalid.
Start-Process -credential (Get-Credential) -FilePath "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
The Start-Process cmdlet has the WorkingDirectory parameter. If we use it with the executable name, the error is one again: The system cannot find the file specified.
Start-Process -credential (Get-Credential) -FilePath "iexplore.exe" -WorkingDirectory "C:\Program Files (x86)\Internet Explorer\"
These errors occur when the $HOMEDRIVE and $HOMEPATH are set on the logged user account. This can be done by GPO or on the account properties.
The workaround is to use the full path of the executable AND uses the working directory:
Start-Process -credential (Get-Credential) -FilePath "C:\Program Files (x86)\Internet Explorer\iexplore.exe" -WorkingDirectory "C:\Program Files (x86)\Internet Explorer\"
When you try to run a process on a computer with an external user in a trusted forest, the user must be in the local computer User group. Otherwise, you will get an Access Denied error.