Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-26
3
Medium Priority
?
1,105 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 71

Accepted Solution

by:
Qlemo earned 2000 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 71

Expert Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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 …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

715 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