Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Performance analysis of my SMB1 detection script.

$
0
0

Hey Everyone, Like many of us, I’m taking steps to mitigate WannaCry, and I’ve written a SMB1 detection script for my servers. It runs, but it’s extremely slow, and I wonder if anyone can help me figure out why. I suspect it has to do with creating an array in my foreach loop, but i can’t find a better way to do it. Any tips?

 $Servers = Get-ADComputer -Filter {(enabled -eq $True) -and (OperatingSystem -like "*Windows Server*")} $table = ForEach ($Server in $Servers) { If ((Test-Connection -ComputerName $Server.Name -Count 1 -quiet) -eq $True) { $query = Invoke-Command -ComputerName $Server.Name -ScriptBlock { Get-SmbServerConfiguration | Select-Object -ExpandProperty EnableSMB1Protocol } [pscustomobject]@{ 'Computer' = $Server.Name 'SMB1 Present' = $query } } Else { Write-Output $Server.Name "is offline" } } $table | Format-Table -autosize 

submitted by /u/artvandelay440
[link] [comments]

The post Performance analysis of my SMB1 detection script. appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Latest Images

Trending Articles



Latest Images