3/1/2011 6:47:18 AM
 Peter C Posts: 16
|
Hi, We are successfully using a Powershell function to get Secrets. But when i try to add a secret i get a Errors.
When i try to call the function without the last parameter (FolderId) i get this Error:
Cannot find an overload for "AddSecret" and the argument count: "4". At Z:\PSadmin\LibPOIADM.ps1:1582 char:36 + $result = $SSConnection.AddSecret <<<< ($template.Id, "$secretName", $fields, $fieldValues) + CategoryInfo : NotSpecified: ( [], MethodException + FullyQualifiedErrorId : MethodCountCouldNotFindBest
------------ When i try to add the FolderId i getantohter Error. I tried for the last parameter: $Folder $Folder.Folder $Folder.Folder.id
[int32]$FolderId = 31 $Folder = $SSConnection.FolderGet($FolderId) $Folder.folder $SSConnection.AddSecret($template.Id, "$secretName", $fields, $fieldValues, $Folder) Id Name TypeId ParentFolderId -- ---- ------ -------------- 31 App-Diverse 1 1 Cannot convert argument "2", with value: "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServic eProxy3vices_SSWinAuthWebService_asmx.SecretField[]", for "AddSecret" to type "System.Int32[]": "Cannot convert the "Mi crosoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3vices_SSWinAuthWebService_asmx.Secret Field" value of type "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3vices_SSWinAu thWebService_asmx.SecretField" to type "System.Int32"." At Z:\PSadmin\LibPOIADM.ps1:4 char:36 + $result = $SSConnection.AddSecret <<<< ($template.Id, "$secretName", $fields, $fieldValues, $Folder.Folder) + CategoryInfo : NotSpecified: ( [], MethodException + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument What do i do wrong?
Thank you! Peter Cermak
|
|
|
0
• link
|
3/1/2011 9:04:40 AM
 Kevin Administrator Posts: 219
|
Hi Peter,
Rather than not specifying the folder ID at all, can you please try specifying -1? That should resolve the issue.
Thanks, -- Kevin Jones
|
|
|
0
• link
|
3/1/2011 10:41:57 AM
 Peter C Posts: 16
|
Hi Kevin, Thank you, but this was my first attempt and brings the same Error. I thought since i have activated "Require Folder For Secrets : Yes" it would bring me the Error and so i tried integers adn then the object approach.
Cannot convert argument "2", with value: "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServic eProxy1vices_SSWinAuthWebService_asmx.SecretField[]", for "AddSecret" to type "System.Int32[]": "Cannot convert the "Mi crosoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_SSWinAuthWebService_asmx.Secret Field" value of type "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vices_SSWinAu thWebService_asmx.SecretField" to type "System.Int32"." At Z:\PSadmin\LibPOIADM.ps1:4 char:36 + $result = $SSConnection.AddSecret <<<< ($template.Id, "$secretName", $fields, $fieldValues, -1) + CategoryInfo : NotSpecified: ( [], MethodException + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
|
|
|
0
• link
|
3/1/2011 4:01:22 PM
 David Posts: 81
|
Hello Peter,
It looks like the error is that you are passing in the secret fields instead of an array of secret field ids.
For example, you can convert $fields to Ids and then pass it in to the AddSecret method:
$secretFieldIds = @() foreach ($field in $fields) { $secretFieldIds += $field.Id }
|
|
|
0
• link
|
3/2/2011 2:48:26 AM
 Peter C Posts: 16
|
Thank you David, of course i did this according to the example you provided somwhere else
$fields = $SSConnection.GetSecretTemplateFields($template.Id).Fields ... $fieldIds = @() $fields | ForEach {$fieldIds = $fieldIds + $_.Id}
Maybe the Porblem is with my FieldValues:
$fieldValues = ("$Machine", "$username", "$password", "$Application", "$DMZ", "$Notes")
Should we handel this via support tickts so i can better send you my Scripts and my Template?
Thanks, Peter
|
|
|
0
• link
|