Memo PowerShell

De Linuxmemo.

Version du 20 février 2017 à 09:43 par Linuxmemo (discuter | contributions)
(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)
  1. lister les methodes et propriétés

$variable | Get-Member $variable | Get-Member -MemberType Method $variable | Get-Member -MemberType Properties

  1. appel des methodes et propriétés

$variable.ToUpper() # methode $variable.Length # propriété

  1. trier

Select-Object -Property <objet>

             -First 5            # pour les collections d'objets

Select-Object Name Select-Object Name,ID Select-Object -Index 5

Get-Service | Group-Object -Property status

Sort-Object # sort

Measure-Object # wc

Compare-Object # diff

Get-Service | Where-Object {$_.Status -EQ 'running'} # | Format-Table -AutoSize

           | Select-String <string>    # grep
  1. afficher
           | Format-List
           | Format-List -Property Name,Length
           | Format-List *
           | Format-Table
           | Format-Table -Property Name,Length
           | Format-Table -AutoSize
           | Out-GridView
  1. objet .NET

$Nb = [System.Convert]::ToString(1234,8)

  1. objet WMI

Get-WmiObject -List | Select-Object -Property Name |Format-Table -AutoSize Get-WmiObject -List | Select-Object -Property Name | Select-String ComputerSystem Get-WmiObject -Class Win32_ComputerSystem

  1. modules et snap-in (dll)

Get-PSSnapin Get-Module Get-Module -ListAvailable Import-Module -Name NetTCPIP # plus utilisé depuis Powershell 3, car automatique

Get-Command -Module NetTCPIP

Outils personnels