Commandes Linux équivalentes sous Windows
Recehrche de fichiers contenant un texte
1DOS> findstr text *.*
2DOS> findstr text c:\repertoire\*.txt
3# dans les sous répertoires
4DOS> findstr /S text *.*
1PowerShell> Select-String -Path "C:\repertoire\*.csv" -Pattern "texte"
2PowerShell> Get-ChildItem -Path C:\repertoire\*.txt -Recurse | Select-String -Pattern 'Texte' -CaseSensitive
Recherche de fichiers par le nom
1DOS> dir /b/s *.txt
2DOS> dir /s *foo*
1PowerShell> Get-ChildItem -Path .\* -Include *.mp4 -Recurse
2PowerShell> Get-ChildItem -Recurse -Path C:\ | Where-Object {$_.Length gt 1MB}
3PowerShell> Get-ChildItem -Path .\* -Include *.mp4 -Recurse | Where-Object { $_.CreationTime -lt '2024-01-01' }
4# exclu des fichiers. Semble ne fonctionner que pour les fichiers, et pas pour les répertoires
5PowerShell> Get-ChildItem -Path . -Recurse -Exclude ('node_modules', 'node', 'target','*.jar') -File
Appel url / telechargement de fichiers
1PowerShell> Invoke-WebRequest https://www.google.fr
2PowerShell> Invoke-WebRequest -Proxy "http://proxy.hostname:8090/" https://www.google.fr
3PowerShell> Invoke-WebRequest -NoProxy https://www.google.fr
4PowerShell> Invoke-WebRequest -SkipCertificateCheck https://www.google.fr
5PowerShell> Invoke-WebRequest [$myDownloadUrl](https://www.google.fr) -OutFile c:\temp\file.html
6PowerShell> Invoke-WebRequest "https://httpbin.org/ip"
Commandes équilavantes à jq
1# curl "https://api.example.com/data" | jq '.someField'
2
3# URL de l'API
4$url = "https://api.example.com/data"
5
6# Appeler l'API et obtenir l'objet JSON
7# Invoke-RestMethod convertit automatiquement la réponse JSON en un objet PowerShell
8$jsonData = Invoke-RestMethod -Uri $url
9
10# Accéder au champ souhaité (remplacez 'someField' par le nom de votre champ)
11$fieldValue = $jsonData.someField
12
13# Afficher la valeur du champ
14Write-Host "La valeur du champ est : $fieldValue"
15
16# Si le champ est imbriqué, par exemple .data.item
17# $fieldValue = $jsonData.data.item
1PowerShell> (Invoke-RestMethod -Uri "https://api.example.com/data").someField(Invoke-RestMethod -Uri "https://api.example.com/data").someField