################################################################################################################################################ ################################################################################################################################################ ################################################# Assembly nécessaire pour la fenêtre graphique ################################################ ################################################################################################################################################ ################################################################################################################################################ Add-Type -AssemblyName PresentationFramework Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName PresentationCore Add-Type -AssemblyName WindowsBase # .Net methods for hiding/showing the console in the background Add-Type -Name Window -Namespace Console -MemberDefinition ' [DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); ' ################################################################################################################################################ ################################################################################################################################################ ############################################################### prérequis ###################################################################### ################################################################################################################################################ ################################################################################################################################################ ## rendre disponible l'optional feature de windows Hyper-V: # => dans la recherche windows : fonctionnalitées facultatives # => se loguer en admin local # => chercher dans le pop-up le module hyper-v pour powershell # => Hyper-V # =>Outils d'administration Hyper-V # => Module Hyper-V pour Windows Powershell # => cocher la case correspondante et valider sur ok, un redémarrage est peut-être nécessaire ################################################################################################################################################ ################################################################################################################################################ ############################## Déclaration de la Hash table qui sera synchronisée entre les différents runspaces ############################### ################################################################################################################################################ ################################################################################################################################################ $syncHash = [hashtable]::Synchronized(@{}) ################################################################################################################################################ ################################################################################################################################################ ############################################ Déclaration du premier runspace pour l'interface graphique ######################################## ################################################################################################################################################ ################################################################################################################################################ $newRunspace =[runspacefactory]::CreateRunspace() $newRunspace.ApartmentState = "STA" ## Le STA est là pour l'interface en WP $newRunspace.ThreadOptions = "ReuseThread" $newRunspace.Open() $newRunspace.SessionStateProxy.SetVariable("syncHash",$syncHash) $psCmd = [PowerShell]::Create().AddScript({ ################################################################################################################################################ ################################################################################################################################################ ############################################ Déclaration du code XAML de l'interface graphique WPF ############################################# ################################################################################################################################################ ################################################################################################################################################ [xml]$Fenetre_principale = @"