如何创建没有密码的 PSCredential 实例?(无需手动填写Get-Credential
没有密码的对话框,这是用于无人值守的运行。)
我尝试过的事情:
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $null)
错误:无法处理参数,因为参数“密码”的值为空$mycreds = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString $null -AsPlainText -Force))
错误:ConvertTo-SecureString:无法将参数绑定到参数“String”,因为它为空。$mycreds = New-Object System.Management.Automation.PSCredential ("username", (ConvertTo-SecureString "" -AsPlainText -Force))
错误:ConvertTo-SecureString:无法将参数绑定到参数“String”,因为它是一个空字符串。