How to create a instance of PSCredential that has no password? (Without manually filling out a Get-Credential
dialog with no password, this is for unattended running.)
Things I tried:
$mycreds = New-Object System.Management.Automation.PSCredential ("username", $null)
Error: Cannot process argument because the value of argument "password" is null
$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.
$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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…