$erroractionPreference="stop"
$pcs =
Get-ADComputer -Filter "Name -like '*'" | select-object name
$pccount =
$pcs.Count
$counter = 1
foreach ($pc in
$pcs) {
    $computername = $pc.name
    if(Test-Connection -ComputerName
$computername -Count 1 -Quiet){
        Try
        {
            $path = "\\" +
$computername + "\c$\users\public"
            Write-Host $counter" of
"$pccount" Searching "$path
            $files = Get-ChildItem -Path $path
| Where-Object {$_.Name -match
"\.(exe|jar|msi|zip|js|vbs|ps1|bat|py|rar|hta)$" } | select fullname
            foreach($file in $files){
                Get-FileHash -Algorithm md5
$file.FullName | select Path, @{l=",";e={","}}, Hash |
Format-Table -AutoSize
            }
        }
        Catch
        {
        Write-Host $counter" of
"$pccount" Search Error "$computername
        }
    }
    else{
        Write-Host $counter" of
"$pccount" Search Connection Failure "$computername
    }
    $counter++
}
No comments:
Post a Comment