Solved

Powershell: command doesn't wait for input in a remote session

Posted on 2013-01-26
3
1,081 Views
Last Modified: 2013-01-26
I try to run a RunAs command in a remote powershell session, but it doesn't let me enter a password, immediately inviting to run another command:
PS C:\Windows\system32> Enter-PSSession comp1
[comp1]: PS C:\Users\admin\Documents> runas /user:user@domain.loc hostname
Enter the password for user@domain.loc:
[comp1]: PS C:\Users\admin\Documents>

Open in new window

How do I enter a password in a remote session?
Thank you.
0
Comment
Question by:PavelTMN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 38822453
RunAs will not work in a remote PS session. The password prompt is coded in a way it hides the input, and that is not supported. Since you configured WinRM already, it is much better to use invoke-command:
invoke-command -Computer comp1 -Script { hostname } -Credentials "user@domain.loc"

Open in new window

or use the -Credential parameter of Enter-PsSession.
0
 
LVL 1

Author Comment

by:PavelTMN
ID: 38822579
Thanks for clearing that out.

The problem with invoke-command is that a limited user, that you want to use credentials of, must have a right to create a PS session to the remote computer which I obviously don't want to give. Even if you do invoke-command in an already admin-opened session it still requires that right for an alternate creds account.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 38823087
Then you might want to use SysInternals PsExec instead.
0

Featured Post

Are You Headed to Black Hat USA 2017?

Getting ready for Black Hat next week? Kick things off with the WatchGuard Badge Challenge and test your puzzle and cipher skills. Do you have what it takes to earn our limited edition Firebox Badge? Get started today - https://crimsonthorn.net

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question