2

I'm trying to write a powershell script that prompts for credentials and opens a webpage as the user. I have

start-process -credential (get-credential) -filepath "http://www.microsoft.com"

It prompts for credentials, but then it outputs "This command cannot be run due to the error: The system cannot find the file specified."

I've tested it without the get-credential piece and it works fine. What am I doing wrong?

1

start-process -credential(get-credential) -filepath "C:\Program Files\Internet Explorer\iexplore.exe" -argumentlist "http://www.microsoft.com"

did the trick

-1

It seems to get confused due to switching credentials during the command -- or something. :)

Try this instead:

start-process -credential (get-credential) -FilePath "powershell" -ArgumentList "start-process http://www.microsoft.com"

This causes it to start a new Powershell instance under the new credentials, and then use that new instance to launch the web page.

  • Receiving the same error, just in a new window =( – Pickle Jul 8 '14 at 21:02
  • What's the exact command line you tried? The one I posted works fine here (Windows 7 64-bit, PowerShell v2). – Ƭᴇcʜιᴇ007 Jul 8 '14 at 21:26
  • I'm trying the exact command line you posted. I can't actually see the error since it opens in a new window and closes, but it looks to be the same. – Pickle Jul 9 '14 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.