Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    PS> $lockedFile="C:\Windows\System32\wshtcpip.dll"
    PS> Get-Process | foreach{$processVar = $_;$_.Modules | foreach{if($_.FileName -eq $lockedFile){$processVar.Name + " PID:" + $processVar.id}}}


    PS C:\> gps |? {$_.Modules.FileName -match "wshtcpip\.dll"} | select name, id


That foreach looks like it should really be a where


It was copied from stackoverflow... apologies, I just knew it was possible.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: