Bonjour,

je programme une fonction simple qui bug pour un probleme de type comment corriger cela ?







Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


$texte="chien ; chat ; cochon"
$recherche="chat"



Function codecontients {
param(
        [Parameter(Mandatory=$true)]
		[string]$srtsource,
		[Parameter(Mandatory=$true)]
		[string]$strech
    )

$flag=0
[string[]]$InputArray=($srtsource).Split(" ; ")

if ($InputArray -contains $strech)
{
$flag=1
}
return $flag
}

if ($(codecontients($texte,$recherche)) -eq 1)
		{
				write-host "chaine $recherche trouvé"

		}
erreur rencontré :



codecontients : Impossible de traiter la transformation d'argument sur le paramètr
convertir la valeur en type System.String.
Au caractère \test.ps1:26 : 20
+ if ($(codecontients($texte,$recherche)) -eq 1)
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData : ( [codecontients], ParameterBindingA
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,codecontients



le but étant d’éclater un texte en tableau et de regarder si l'un des membres de ce tableau est le texte recherché

en vous remerciant,