【发布时间】:2015-04-12 17:48:13
【问题描述】:
在 powershell 中,我想使用存储在 $uname, $pass 中的用户名和密码。这些实际上是从文件中读取的,并在每次脚本执行时存储在 $uname 和 $pass 中。我试过了
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $uname,$pass
但错误是
new-object : Cannot find an overload for "PSCredential" and the argument count: "2".
我需要稍后在脚本中将这些凭据用于 New-PsSession。有人能尽快帮忙吗?
【问题讨论】:
-
@@serverstackqns 我没有这方面的知识,但这可能对你有帮助powertoe.wordpress.com/2011/06/05/…
-
@PathumAnjana:谢谢,但文件中存储的密码是纯文本格式。请参考这个问题了解我的文件内容结构:stackoverflow.com/questions/29559282/…