rj07thomas

Report SMB1

Jul 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. [string]$serverList
  2.  
  3. [string]$serverNames
  4.  
  5. [int]$reponsiveCounter =0
  6.  
  7. [int]$unreponsiveCounter =0
  8.  
  9.  
  10.  
  11. $serverList = Get-ADComputer -LDAPFilter “(&(ObjectCategory=Computer))” | Select-Object Name
  12.  
  13. $serverNames = $serverList.Name
  14.  
  15.  
  16.  
  17. ForEach ($server in $serverNames)
  18.  
  19. {
  20.  
  21. $isAlive = Test-Connection $server -Count 1 -Quiet
  22.  
  23.  
  24.  
  25. If($isAlive -eq $true)
  26.  
  27. {
  28.  
  29. [console]::ForegroundColor = "Green"
  30.  
  31. [console]::BackgroundColor = "DarkRed"
  32.  
  33. Write-Host $server " is responding"
  34.  
  35. Invoke-Command -ComputerName $server -ScriptBlock {$myPC = New-PSSession "somePC"; Import-PSSession -session $myPC -module SmbShare; Get-SMBServerConfiguration | Select-Object Name,EnableSMB1Protocol,EnableSMB2Protocol | FT}
  36.  
  37. $responsiveCounter++
  38.  
  39. }
  40.  
  41. ElseIf($isAlive -eq $false)
  42.  
  43. {
  44.  
  45. [console]::ForegroundColor = "Blue"
  46.  
  47. [console]::BackgroundColor = "Yellow"
  48.  
  49. Write-Host $server " is not responding"
  50.  
  51. $unresponsiveCounter++
  52.  
  53. }
  54.  
  55.  
  56.  
  57. }
  58.  
  59.  
  60.  
  61. Write-Host “`n`nThe total number of responsive devices is ” $responsiveCounter
  62.  
  63. Write-Host “`n`nThe total number of unresponsive devices is ” $unresponsiveCounter
Advertisement
Add Comment
Please, Sign In to add comment