PSCredential的创建没有密码 [英] Create PSCredential without a password

查看:1879
本文介绍了PSCredential的创建没有密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建PSCredential的没有密码一个实例?

我试过

东西:

  1. $ mycreds =新对象System.Management.Automation.PSCredential(用户名,$空) 错误:无法处理参数,因为参数密码的值为null

  2. $ mycreds =新对象System.Management.Automation.PSCredential(用户名,(的ConvertTo-S​​ecureString的$空-AsPlainText -Force)) 错误:的ConvertTo-S​​ecureString的:无法绑定参数参数'串',因为它是空

  3. $ mycreds =新对象System.Management.Automation.PSCredential(用户名,(的ConvertTo-S​​ecureString的-AsPlainText -Force)) 错误:的ConvertTo-S​​ecureString的:无法绑定参数,参数字符串,因为它是一个空字符串

解决方案

解决方法:

  $ mycreds =新对象System.Management.Automation.PSCredential(用户名,(新对象为System.Security.SecureString))
 

对不起,愚蠢的问题。我使用PowerShell的首次不研究。速成班!

How to create a instance in PSCredential that has no password?

Things I tried:

  1. $mycreds = New-Object System.Management.Automation.PSCredential ("username", $null) Error: Cannot process argument because the value of argument "password" is null

  2. $mycreds = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString $null -AsPlainText -Force)) Error: ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null.

  3. $mycreds = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString "" -AsPlainText -Force)) Error: ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is an empty string.

解决方案

Solution:

$mycreds = New-Object System.Management.Automation.PSCredential ("username", (new-object System.Security.SecureString))

Sorry for the dumb question. I'm using Powershell for the first time without studying. A crash course!

这篇关于PSCredential的创建没有密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆