I am an administrator and learning about scripts but was trying to create a script to open multiple programs as another user (my admin password)
The following script runs well when run from powershell ise but won't run properly when right clicking and selecting "run with powershell"
Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -Credential "domain\userid"
When run it prompts for password but doesn't bring up google chrome. It works OK when run from Powershell ISE and I get error "The directory name is invalid" when running the script from Powershell.exe (not the ISE environment).
start-process -filepath c:\asdfasdf\asdf.exethe error which comes back is "This command cannot be run due to the error: The system cannot find the file specified", not "The directory name is invalid". I guess this is either in the configuration of your context menu "Run with PowerShell", maybe it has an invalid path to the PowerShell interpreter, or the PowerShell.exe process can't read the path to your script (but I can't reproduce that error here with some quick testing). Is the error a PowerShell exception or an Explorer dialog box?powershell.exe -nop "C:\path to your script.ps1"