🇹🇷 Piping Nedir? (| Operatörü)
📌 Tanım:
Piping, PowerShell’de bir komuttan çıkan çıktının doğrudan başka bir komuta aktarılması işlemidir. Bu işlem |
(pipe) sembolü ile yapılır.
Bu yapı, Komut1
tarafından üretilen nesneleri Komut2
’ye girdi olarak gönderir.
🧠 Neden Kullanılır?
-
Komutları zincirleme bağlamak için.
-
Veriyi aşamalı olarak işlemek için.
-
Kod okunabilirliğini ve verimliliği artırmak için.
📦 Pipe İşlemi Nasıl Çalışır?
PowerShell'de pipe ile aktarılan veri düz metin değil, .NET nesneleridir. Bu yönüyle PowerShell, Unix/Linux shell'lerinden farklıdır.
Örnek:
-
Get-Process
: Tüm çalışan süreçleri getirir. -
Where-Object
: CPU kullanımı 100'den fazla olanları filtreler. -
$_
: Her bir işlem nesnesini temsil eder (pipe içindeki geçici değişken).
💡 Diğer Kullanım Örnekleri:
Tüm servisleri durumlarına göre sıralar.
Dosya isimleri ve boyutlarını listeler.
⚠️ Güvenlik Açısından Dikkat:
-
Pipe edilen komutlar zincirlenirken istemeden hassas veri dışarı çıkabilir.
-
Kötü niyetli bir kullanıcı, pipe ile veriyi dışa aktarıp sızdırabilir:
Bu yüzden pipe zincirleri güvenlik denetiminde incelenmelidir.
🇬🇧 What is Piping (| Operator)?
📌 Definition:
Piping in PowerShell refers to the chaining of commands, where the output of one command is passed as input to another, using the pipe symbol |
.
This allows for sequential processing of data.
🧠 Why Is It Used?
-
To link multiple commands together.
-
To process data in stages.
-
To write cleaner, more efficient code.
📦 How Does It Work?
In PowerShell, data passed through a pipe is not plain text, but actual .NET objects. This differs from traditional shells like Bash, where piping passes strings.
Example:
-
Get-Process
: Lists running processes. -
Where-Object
: Filters those using more than 100 CPU. -
$_
: Represents the current object in the pipe.
💡 Other Usage Examples:
Sorts all services by status.
Lists file names and their sizes.
⚠️ Security Consideration:
-
Piping data can accidentally expose sensitive info.
-
Malicious actors may use pipes to exfiltrate data:
Therefore, pipeline chains should be audited carefully in security contexts.