Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot process argument transformation on parameter 'Password'. Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString". #27

Open
shamantix opened this issue Oct 7, 2021 · 3 comments

Comments

@shamantix
Copy link

I'm getting this error for all items in the csv while running the datasource-bulk-import.ps1 script.

Full Detail:

DataSourceType ciscoswitch
CiscoSwitchType CATALYST_4500
CollectorVMId 10000:901:4901612053106772451
Username network
Password password
IP 192.168.1.50
Nickname NICKNAME-1
[10/07/2021 16:28:03] Exception:

Message : Cannot process argument transformation on parameter 'Password'. Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString".
ParameterName : Password
ParameterType : System.Security.SecureString
TypeSpecified : System.String
ErrorId : ParameterArgumentTransformationError
Line : 104
Offset : 33
CommandInvocation : System.Management.Automation.InvocationInfo
ErrorRecord : Cannot process argument transformation on parameter 'Password'. Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString".
WasThrownFromThrowStatement : False
TargetSite : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
StackTrace : at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) in
/PowerShell/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs:line 1655
at lambda_method250(Closure , Object[] , StrongBox1[] , InterpretedFrame ) Data : {} InnerException : System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString". ---> System.Management.Automation.PSInvalidCastException: Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString". at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4911 at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4299 at System.Management.Automation.LanguagePrimitives.ConversionData1.Invoke(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert,
IFormatProvider formatProvider, TypeTable backupTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4391
at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable
backupTypeTable) in /PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 4850
at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, IFormatProvider formatProvider) in
/PowerShell/src/System.Management.Automation/engine/LanguagePrimitives.cs:line 1739
at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean
bindingScriptCmdlet) in /PowerShell/src/System.Management.Automation/engine/ArgumentTypeConverterAttribute.cs:line 142
--- End of inner exception stack trace ---
at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, Boolean
bindingScriptCmdlet) in /PowerShell/src/System.Management.Automation/engine/ArgumentTypeConverterAttribute.cs:line 165
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags
flags) in /PowerShell/src/System.Management.Automation/engine/ParameterBinderBase.cs:line 399
HelpLink :
Source : System.Management.Automation
HResult : -2146233087

@smitmartijn
Copy link
Contributor

Ah, yes. I was meaning to update the examples to use the new SecureString format. Try again with the updated script.

@shamantix
Copy link
Author

Ok. I've tried with the updated script and it fails with another error:

PS /home/user> ./datasource-bulk-import.ps1 ./cisco-import1.csv
[10/08/2021 09:49:43] Adding a ciscoswitch Data Source with IP 192.168.0.50..
[10/08/2021 09:49:43] Unable to add data source with parameters:

Name Value


DataSourceType ciscoswitch
CiscoSwitchType CATALYST_3000
CollectorVMId 10000:901:4901612053106772856
Username test
Password System.Security.SecureString
IP 192.168.0.50
Nickname MYNICKNAME_TEST
[10/08/2021 09:49:43] Exception:

ErrorRecord : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again."
WasThrownFromThrowStatement : False
TargetSite : System.Object AuxiliaryConstructorInvoke(System.Management.Automation.MethodInformation, System.Object[], System.Object[])
StackTrace : at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments) in
/PowerShell/src/System.Management.Automation/engine/CoreAdapter.cs:line 4189
at System.Management.Automation.DotNetAdapter.InvokeResolvedConstructor(MethodInformation bestMethod, Object[] newArguments, Object[] arguments) in
/PowerShell/src/System.Management.Automation/engine/CoreAdapter.cs:line 4356
at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments) in
/PowerShell/src/System.Management.Automation/engine/CoreAdapter.cs:line 4345
at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args) in
/PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs:line 77
Message : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again."
Data : {}
InnerException : System.Management.Automation.PSArgumentException: Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again.
at System.Management.Automation.Utils.CheckArgForNullOrEmpty(String arg, String argName) in /PowerShell/src/System.Management.Automation/engine/Utils.cs:line 348
at System.Management.Automation.PSCredential..ctor(String userName, SecureString password) in /PowerShell/src/System.Management.Automation/engine/Credential.cs:line 207
HelpLink :
Source : System.Management.Automation
HResult : -2146233087

My csv:

DatasourceType;IP;Username;Password;Nickname;CISCO_SWITCHTYPE;SnmpCommunity
ciscoswitch;192.168.0.50;test;test123;MYNICKNAME_TEST;CATALYST_3000;public

@shamantix
Copy link
Author

Found the issue. You are missing $Username in PowerVRNI.psm1 @
Line 1620 $cred = New-Object System.Management.Automation.PSCredential("", $Password)
Line 2264 $Authentication = New-Object System.Management.Automation.PSCredential("", $AuthenticationPassword)
Line 2265 $Privacy = New-Object System.Management.Automation.PSCredential("", $PrivacyPassword)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants