Sometimes we have a nice day when we want to defeat evil and make life worse for users. Today’s the day 🙂 – let’s start the hunting!
#madeBy krai.be #-------------[deklarations]-------------------------- #source $computers=Get-Content '\\host\shares\!scripts\!source\!computers.txt' #logs $successLog='\\host\shares\!scripts\!logs\done.LOG' $errorLog='\\host\shares\!scripts\!logs\error.LOG' $unreachableLog='\\host\shares\!scripts\!logs\unreachable.LOG' $reportLog='\\host\shares\!scripts\!reports\pirateHideouts.LOG' #params #-------------[functions]-------------------------- foreach($computer in $computers) { if(Test-Connection -ComputerName $computer -Count 1 -Quiet) { Try { Write-host "I searching bad Pirates: $computer" -foreground 'gray' $file = Invoke-Command -computerName $computer -ScriptBlock {Get-ChildItem -Path C:\Users -Include *.exe, *.mp3, *.mp4, *.wav -File -Recurse -ErrorAction SilentlyContinue | % { Write-Output $env:COMPUTERNAME $_.FullName }} $file >> $reportLog Write-host "checked: $computer" -foreground 'green' $computer >> $successLog } Catch { Write-host "error: $computer" -foreground 'red' $computer >> $errorLog } } else { Write-host "offline: $computer" -foreground 'yellow' $computer >> $unreachableLog } }