Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

PowerShellISE+

Publié le par damcuvelier

Imaginez que vous utilisiez PowerShell ISE.
Imaginez que vous ayez besoin de savoir quelle valeur renseigner dans quelle case.
Imaginez que vous vouliez accéder directement aux détails — comme l'URL officielle d'un cmdlet.

Ne perdez plus de temps avec la version standard : découvrez PowerShell ISE+.

PowerShell ISE+ vous propose une interface graphique fluide, moderne et intuitive, conçue spécialement pour les administrateurs système, les ingénieurs cloud et les experts PowerShell.
Avec son intégration native des modules stratégiques (Microsoft, VMware...) et son environnement épuré, sans distractions inutiles, ISE+ optimise votre productivité tout en enrichissant votre expérience de scripting.
Déployez vos scripts, automatisez vos tâches les plus complexes et gagnez un temps précieux — le tout dans un éditeur graphique pensé par et pour les professionnels du PowerShell.

PowerShell ISE+ : parce qu'un bon script mérite un meilleur éditeur.

 

Voici le code pour le script "ISEplus.ps1" (tout intégré, rien d'autre à faire que de l'executer en admin par contre):

$InformationPreference = "SilentlyContinue"
$ProgressPreference = "SilentlyContinue"
$VerbosePreference = "SilentlyContinue"
$WarningPreference = "SilentlyContinue"
$ErrorActionPreference = "SilentlyContinue"


# Chargement des composants WPF
Add-Type -AssemblyName PresentationFramework

# --- Contenu XAML ---
$xaml = @"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        Title="ISE Plus" Height="600" Width="950" WindowStartupLocation="CenterScreen">
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,10">
            <TextBlock Name="LabelSearchText" VerticalAlignment="Center"/>
            <TextBox Name="CmdSearchBox" Width="300" Margin="5,0"/>
        </StackPanel>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="3*"/>
            </Grid.ColumnDefinitions>

            <ListBox Name="CmdletList" Grid.Column="0" Margin="0,0,5,0"/>

            <StackPanel Grid.Column="1">
                <TextBlock Name="LabelSwitchText" FontWeight="Bold" Margin="0,0,0,5"/>
                <ListBox Name="SwitchParamsList" Height="100"/>
                <TextBlock Name="LabelInputText" FontWeight="Bold" Margin="10,10,0,5"/>
                <ListBox Name="InputParamsList" Height="100"/>
                <TextBlock Name="LabelValuesText" FontWeight="Bold" Margin="10,10,0,5"/>
                <ListBox Name="ValuesList" Height="120"/>

                <TextBlock Name="CmdletHelpLink" FontStyle="Italic" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="10,10,0,0"/>

            </StackPanel>
        </Grid>

        <Button Grid.Row="2" Name="CloseBtn" Width="100" HorizontalAlignment="Right"/>
    </Grid>
</Window>

"@

# --- Contenu Langues.xml ---
$langXMLContent = @"
<Langues>
  <Langue code="fr-FR">
    <labelSwitch>Paramètres très booléens (switch) :</labelSwitch>
    <labelInput>Paramètres avec valeurs attendues :</labelInput>
    <labelValues>Valeurs possibles :</labelValues>
    <labelSearch>Recherche de Cmdlet :</labelSearch>
    <labelClose>Fermer</labelClose>
    <typeString>Type attendu : Chaîne de caractères (ex : chemin, nom, texte)</typeString>
    <typeInt>Type attendu : Entier (ex : 0, 1, 10…)</typeInt>
    <typeBool>Type attendu : Vrai ou Faux</typeBool>
    <typeDate>Type attendu : Date/Heure (ex : 2025-01-01)</typeDate>
    <typeSecure>Type attendu : Mot de passe sécurisé</typeSecure>
    <typeArray>Type attendu : Liste de chaînes (ex : a,b,c)</typeArray>
  </Langue>
  <Langue code="en-US">
    <labelSwitch>Boolean parameters (switch):</labelSwitch>
    <labelInput>Parameters with input values:</labelInput>
    <labelValues>Possible values:</labelValues>
    <labelSearch>Cmdlet Search:</labelSearch>
    <labelClose>Close</labelClose>
    <typeString>Expected type: String (e.g., path, name, text)</typeString>
    <typeInt>Expected type: Integer (e.g., 0, 1, 10)</typeInt>
    <typeBool>Expected type: Boolean (True or False)</typeBool>
    <typeDate>Expected type: Date/Time (e.g., 2025-01-01)</typeDate>
    <typeSecure>Expected type: Secure string (password)</typeSecure>
    <typeArray>Expected type: Array of strings (e.g., a,b,c)</typeArray>
  </Langue>
</Langues>

"@

# Lecture du XAML intégré
$reader = New-Object System.Xml.XmlTextReader([System.IO.StringReader]::new($xaml))
$reader.XmlResolver = $null
$window = [Windows.Markup.XamlReader]::Load($reader)

# --- Logique principale PowerShell ---
. {
# Add-Type already included above

$culture = (Get-Culture).Name
[xml]$langXML = $langXMLContent
$lang = $langXML.Langues.Langue | Where-Object { $_.code -eq $culture }
if (-not $lang) { $lang = $langXML.Langues.Langue | Where-Object { $_.code -eq "en-US" } }

$reader = New-Object System.Xml.XmlTextReader([System.IO.StringReader]::new($xaml))
$reader.XmlResolver = $null
$window = [Windows.Markup.XamlReader]::Load($reader)

$searchBox        = $window.FindName("CmdSearchBox")
$cmdList          = $window.FindName("CmdletList")
$switchParamsList = $window.FindName("SwitchParamsList")
$inputParamsList  = $window.FindName("InputParamsList")
$valuesList       = $window.FindName("ValuesList")
$labelSearchText  = $window.FindName("LabelSearchText")
$labelSwitchText  = $window.FindName("LabelSwitchText")
$labelInputText   = $window.FindName("LabelInputText")
$labelValuesText  = $window.FindName("LabelValuesText")
$closeBtn         = $window.FindName("CloseBtn")
$cmdletHelpLink   = $window.FindName("CmdletHelpLink")

$labelSearchText.Text = $lang.labelSearch
$labelSwitchText.Text = $lang.labelSwitch
$labelInputText.Text  = $lang.labelInput
$labelValuesText.Text = $lang.labelValues
$closeBtn.Content     = $lang.labelClose

$closeBtn.Add_Click({ $window.Close() })

if ($cmdletHelpLink) {
    $cmdletHelpLink.Add_MouseLeftButtonUp({
        if ($cmdletHelpLink.Text) {
            Start-Process $cmdletHelpLink.Text
        }
    })
}

$allCmdlets = Get-Command -CommandType Cmdlet | Sort-Object Name
foreach ($cmd in $allCmdlets) {$null = $cmdList.Items.Add($cmd.Name)}

$searchBox.Add_TextChanged({
    $filter = $searchBox.Text.ToLower()
    $cmdList.Items.Clear()
    foreach ($cmd in $allCmdlets) {
        if ($cmd.Name.ToLower().Contains($filter)) {
            $cmdList.Items.Add($cmd.Name)
        }
    }
})

$cmdList.Add_SelectionChanged({
    $switchParamsList.Items.Clear()
    $inputParamsList.Items.Clear()
    $valuesList.Items.Clear()
    $cmdName = $cmdList.SelectedItem

    if ($cmdName) {
        $cmdMeta = Get-Command $cmdName
        $moduleName = $cmdMeta.ModuleName
        $cmdLinkName = $cmdMeta.Name

        if ($cmdletHelpLink -and $moduleName -and $cmdLinkName) {
            $baseUrl = "https://learn.microsoft.com/powershell/module/"
            $url = "$baseUrl$moduleName/$cmdLinkName".ToLower()
            if ($cmdletHelpLink -and $moduleName -and $cmdLinkName) {
            if ($moduleName -like "Microsoft.*" -or $moduleName -like "Az.*") {
                $baseUrl = "https://learn.microsoft.com/powershell/module/"
                $url = "$baseUrl$moduleName/$cmdLinkName".ToLower()
            }
            elseif ($moduleName -like "VMware.*") {
                $baseUrl = "https://developer.vmware.com/docs/powercli/latest/"
                $url = "$baseUrl$moduleName/commands/$cmdLinkName".ToLower()
            }
            else {
                $url = ""
            }

            $cmdletHelpLink.Text = $url
            $cmdletHelpLink.ToolTip = "Ouvrir la documentation"
        }
        }

        foreach ($param in $cmdMeta.Parameters.Values) {
            if ($param.ParameterType.Name -eq 'SwitchParameter') {
                $switchParamsList.Items.Add($param.Name)
            } else {
                $inputParamsList.Items.Add($param.Name)
            }
        }
    }
})

$inputParamsList.Add_SelectionChanged({
    $valuesList.Items.Clear()
    $cmdName = $cmdList.SelectedItem
    $paramName = $inputParamsList.SelectedItem
    if ($cmdName -and $paramName) {
        $paramMeta = (Get-Command $cmdName).Parameters[$paramName]
        $found = $false
        foreach ($attr in $paramMeta.Attributes) {
            if ($attr -is [System.Management.Automation.ValidateSetAttribute]) {
                foreach ($val in $attr.ValidValues) {
                    $valuesList.Items.Add($val)
                }
                $found = $true
            }
        }
        if (-not $found -and $paramMeta.ParameterType.IsEnum) {
            [Enum]::GetNames($paramMeta.ParameterType) | ForEach-Object { $valuesList.Items.Add($_) }
            $found = $true
        }
        if (-not $found) {
            $typeName = $paramMeta.ParameterType.Name.ToLower()
            $desc = switch ($typeName) {
                "string"       { $lang.typeString }
                "int32"        { $lang.typeInt }
                "boolean"      { $lang.typeBool }
                "datetime"     { $lang.typeDate }
                "securestring" { $lang.typeSecure }
                "string[]"     { $lang.typeArray }
                default        { "Type attendu : $($paramMeta.ParameterType.Name)" }
            }
            $valuesList.Items.Add($desc)
        }
    }
})


$switchParamsList.Add_SelectionChanged({
    $valuesList.Items.Clear()
    $valuesList.Items.Add("[switch]")
})


$window.ShowDialog() | Out-Null

}
 

 

Commenter cet article