Memo PowerShell
De Linuxmemo.
Version du 21 février 2017 à 16:00 par Linuxmemo (discuter | contributions)
Sommaire |
lister les methodes et propriétés
$variable | Get-Member $variable | Get-Member -MemberType Method $variable | Get-Member -MemberType Properties
appel des methodes et propriétés
$variable.ToUpper() # methode $variable.Length # propriété
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
afficher
| Format-List | Format-List -Property Name,Length | Format-List *
| Format-Table | Format-Table -Property Name,Length | Format-Table -AutoSize
| Out-GridView
objet .NET
$Nb = [System.Convert]::ToString(1234,8)
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
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