Je ne vous apprendrai rien, l’environnement en ligne de commande fournit avec les systèmes Windows est très pauvre en tout point de vue. C’est pour palier à ce manque et pour être au niveau des différents shells Unix et autres Perl, Kixstart ou VBScript que Microsoft propose PowerShell. Voyons aujourd’hui comment installer PowerShell sur un système Windows et tester qu’il est bien fonctionnel.

Installer PowerShell

PowerShell est supporté aujourd’hui uniquement par les systèmes suivants:

  • Windows XP Service Pack 2
  • Windows Server 2003 Service Pack 1
  • Windows Vista
  • Windows Seven
  • Windows Server 2008

Si votre système est supporté vous aurez alors à installer le .NET Framework 2.0

http://www.google.fr/search?hl=fr&q=.NET+Framework+2.0&btnG=Recherche+Google&meta=

Puis installer le package PowerShell correspondant à votre système

http://syskb.com/telecharger-windows-powershell-20-ctp/

PowerShell - Installation - Etape 1 PowerShell - Installation - Etape 2 PowerShell - Installation - Etape 3

A noter que pour Windows Seven et Windows Server 2008 PowerShell est déjà intégré !

Lancer PowerShell sur Windows 2003 / XP ou Vista

Une fois votre nouvel environnement de Scripting PowerShell installé il ne reste plus qu’à vérifier qu’il est bien fonctionnel.

Pour lancer PowerShell je vous propose plusieurs solutions:

  • Lancer Windows PowerShell à partir du menu Démarrer / Programmes / Windows PowerShell 1.0
  • Créer un raccourci de powershell.exe à partir de C:\Windows\System32\windowspowershell\v1.0
  • Taper powershell directement dans Démarrer / Exécuter

PowerShell - Interface

Lancer PowerShell sur Windows Seven et Windows Server 2008

Powershell 2.0 étant déja intégré il vous suffit de presser la touche WIN + R et de taper Powershell puis ENTER pour lancer l’interpréteur.

Exécuter une commande

Nous allons exécuter notre première “cmdlets”. Une fois dans l’interpréteur PowerShell, exécuter la commande suivante:

get-help get-command

La commande get-help vous sera par la suite très utile pour obtenir une information sur une autre commande. C’est un peu l’équivalent du man sous Linux.

La commande get-command permet d’afficher toutes les commandes PowerShell disponible. PowerShell propose plus de 130 commandes.

Le couple get-help get-command permet comme vous pouvez vous en douter d’obtenir de l’aide sur la commande get-command

Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. Tous droits réservés.
PS C:\Documents and Settings\syskb> get-help get-command
NOM
Get-Command
RÉSUMÉ
Obtient des informations de base sur les applets de commande et sur d'autre
s éléments des commandes Windows PowerShell.

SYNTAXE
Get-Command [[-argumentList] <Object[]>] [-verb <string[]>] [-noun <string[
]>] [-totalCount <int>] [-syntax] [-pSSnapIn <string[]>] [<CommonParameters
>]

Get-Command [[-name] <string[]>] [[-argumentList] <Object[]>] [-commandType
{<Alias> | <Function> | <Filter> | <Cmdlet> | <ExternalScript> | <Applicat
ion> | <Script> | <All>}] [-totalCount <int>] [-syntax] [<CommonParameters>
]

DESCRIPTION DÉTAILLÉE
L'applet de commande Get-Command obtient des informations de base sur les a
pplets de commande et d'autres éléments des commandes Windows PowerShell, t
els que les fichiers, les fonctions et les fournisseurs de Windows PowerShe
ll.

LIENS CONNEXES
Get-Help
Get-PSDrive
Get-Member

REMARQUES
Pour plus d'informations, tapez : "get-help Get-Command -detailed".
Pour obtenir des informations techniques, tapez : "get-help Get-Command -fu
ll".

PS C:\Documents and Settings\syskb>

Vous savez désormais installer Powershell sur un environnement Windows. Je vous propose maintenant de voir comment exécuter un script en Powershell