Bonjour à tous,

C'est un programme pour créer des comptes AD, et il y a trois fenêtres à faire apparaître.
Comment faire pour masquer la première et faire apparaître la seconde par exemple ?

Sur le web j'ai trouvé plusieurs fonctions show-powershell (pour afficher) et Hide-Powershell (pour masquer) mais sans succès.

Code de la fonction et aussi en lancement il y a des erreurs :

Code powershell : 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Function Invoke-Win32 ( [string] $dllName, 
                        [Type] $returnType,
                        [string] $methodName, 
                        [Type[]] $parameterTypes, 
                        [Object[]] $parameters) {
 
    #Fonction récupéré sur http://powershell-scripting.com
    ## Begin to build the dynamic assembly
    $domain = [AppDomain]::CurrentDomain
    $name = New-Object Reflection.AssemblyName 'PInvokeAssembly'
    $assembly = $domain.DefineDynamicAssembly($name, 'Run')
    $module = $assembly.DefineDynamicModule('PInvokeModule')
    $type = $module.DefineType('PInvokeType', "Public,BeforeFieldInit")
 
    # Go through all of the parameters passed to us.  As we do this,
    # we clone the user's inputs into another array that we will use for
    # the P/Invoke call.
    $inputParameters = @()
    $refParameters = @()
 
    for($counter = 1 ; $counter -le $parameterTypes.Length ; $counter++) {
        # If an item is a PSReference, then the user
        # wants an [out] parameter.
        if ($parameterTypes[$counter - 1] -eq [Ref]) {
            # Remember which parameters are used for [Out] parameters
            $refParameters += $counter
 
            # On the cloned array, we replace the PSReference type with the
            # .Net reference type that represents the value of the PSReference,
            # and the value with the value held by the PSReference.
            $parameterTypes[$counter - 1] = $parameters[$counter - 1].Value.GetType().MakeByRefType()
            $inputParameters += $parameters[$counter - 1].Value
        } else {
            # Otherwise, just add their actual parameter to the input array.
            $inputParameters += $parameters[$counter - 1]
        }
    }
 
    # Define the actual P/Invoke method, adding the [Out] attribute for any parameters that were 
    # originally [Ref] parameters.
    $method = $type.DefineMethod($methodName, 'Public,HideBySig,Static,PinvokeImpl', $returnType, $parameterTypes)
    foreach ($refParameter in $refParameters) {
        $method.DefineParameter($refParameter, "Out", $null)
    }
 
    # Apply the P/Invoke constructor
    $ctor = [Runtime.InteropServices.DllImportAttribute].GetConstructor([string])
    $attr = New-Object Reflection.Emit.CustomAttributeBuilder $ctor, $dllName
    $method.SetCustomAttribute($attr)
 
    #Create the temporary type, and invoke the method.
    $realType = $type.CreateType()
    $realType.InvokeMember($methodName, 'Public,Static,InvokeMethod', $null, $null, $inputParameters)
 
    # Finally, go through all of the reference parameters, and update the values of the PSReference 
objects that the user passed in.
    foreach ($refParameter in $refParameters) {
        $parameters[$refParameter - 1].Value = $inputParameters[$refParameter - 1]
    }
}
 
Function Hide-PowerShell() { 
    $global:myWindowHandle = (Get-Process -Id $pid).MainWindowHandle
    $null = ShowWindowAsync $((Get-Process -Id $pid).MainWindowHandle)  0
}
 
 
 Function Show-PowerShell() { 
     $null = ShowWindowAsync $($global:myWindowHandle)  1
}
 
Function ShowWindowAsync([IntPtr] $hWnd, [Int32] $nCmdShow)
{
    #0 Cache la fenetre
    #1 Montre la fenetre
    #2 Minimize la fenetre
    $parameterTypes = [IntPtr], [Int32] 
    $parameters = $hWnd, $nCmdShow
 
    Invoke-Win32 "user32.dll" ([Boolean]) "ShowWindowAsync" $parameterTypes $parameters
    }

J'ai trouvé un moyen d'afficher les deux fenêtres et de les fermer en même temps quand je clique sur le bouton suivant de l'interface.

Avec ça :

Code powershell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
$Suivant.Add_Click({
if ($Ext.IsChecked){
 }
 
if ($In.IsChecked){
 
$Form.ShowDialog()
$Intro.visibility=1
 }             
})

Voila si quelqu'un a une idée merci d'avance.