Solved

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

Posted on 2013-01-26
3
997 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
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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
Comment Utility
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 68

Expert Comment

by:Qlemo
Comment Utility
Then you might want to use SysInternals PsExec instead.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now