Windows Dev Center

PSHostUserInterface.PromptForCredential Method (String, String, String, String)

When overridden in a derived class, prompts the user for credentials with a specified prompt window caption, prompt message, user name, and target name.

Namespace: System.Management.Automation.Host
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim instance As PSHostUserInterface
Dim caption As String
Dim message As String
Dim userName As String
Dim targetName As String
Dim returnValue As PSCredential

returnValue = instance.PromptForCredential(caption, message, userName, targetName)

public abstract PSCredential PromptForCredential (
	string caption,
	string message,
	string userName,
	string targetName
public abstract PSCredential PromptForCredential (
	String caption, 
	String message, 
	String userName, 
	String targetName
public abstract function PromptForCredential (
	caption : String, 
	message : String, 
	userName : String, 
	targetName : String
) : PSCredential



The caption for the message window.


The text of the message.


The user name whose credential is to be prompted for. If this parameter set to null or an empty string, the function prompts for the user name first.


The name of the target for which the credential is collected.

Return Value

A PSCredential object that contains the credentials for the target.

Exception typeCondition

The host can throw this exception when it cannot complete an operation.


If this method is not implemented, the host should throw a "not implemented" exception when it receives this call.


The host can throw this exception when an error occurs while a command is running.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Target Platforms

© 2015 Microsoft