使用凭据运行申请表格Powershell

时间:2015-04-22 09:57:20

标签: powershell passwords username autofill

我使用Invoke-Item命令启动应用程序。当我运行它时,它会提示输入用户名和密码。我想通过PowerShell自动填写,这可以实现吗?

1 个答案:

答案 0 :(得分:0)

您可以使用[-Credential <PSCredential>] PSCredential object参数执行此操作:

# Edit your creds here
$user = "Domain\Username"
$password = ConvertTo-SecureString "MyPassword" -AsPlainText -Force

$mycreds = New-Object System.Management.Automation.PSCredential ($user, $password)
Invoke-Item "Your Application" -Credential $mycreds