I'm trying to accept username and password as params to a Powershell script but the new-Object
$UserID="Name"
$SecurePassword=convertto-securestring -AsPlainText -Force -String $Password
New-object –TypeName System.Management.Automation.PSCredential –ArgumentList ($UserID,$SecurePassword)
Gives an error
New-object : Cannot find type [â€TypeName System.Management.Automation.PSCredential â€ArgumentList]: verify that the as sembly containing this type is loaded. At C:\ps\login.ps1:14 char:17 + ... rCredential=New-object –TypeName System.Management.Automation.PSCre ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Anybody got some clues how to solve this?
–
in front ofArgumentList
is not a hyphen, but an EN dash (U+2013), replace it with a hyphen (-
) – Mathias R. Jessen