Guest User

Untitled

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. function Get-DomainControllers([string]$BaseDN){
  2. $strFilter = "(&(objectCategory=Computer))"
  3.  
  4. $objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://ou=domain controllers,"+ $BaseDN)
  5.  
  6. $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
  7. $objSearcher.SearchRoot = $objDomain
  8. $objSearcher.PageSize = 1000
  9. $objSearcher.Filter = $strFilter
  10. $objSearcher.SearchScope = "Subtree"
  11.  
  12. $colResults = $objSearcher.FindAll()
  13. $dc = @()
  14. foreach($objResult in $colResults){
  15. $objItem = $objResult.Properties
  16. $dc += $objItem.name
  17. }
  18.  
  19. return $dc
  20. }
  21.  
  22. function Run-Report([string]$computer){
  23. $path = "C:\Users\lfalk\Desktop\AD_Helth_Check\"+$computer+"\"
  24. if ((Test-Path -path $path) -ne $true)
  25. {
  26. New-Item $path -type directory
  27. }
  28.  
  29. $tempPath = $path+"DCDiag.txt"
  30. echo "**** Running DCDiag Status ****" > $tempPath
  31. Invoke-Command -ComputerName $computer -ScriptBlock { dcdiag /v } >> $tempPath
  32.  
  33. $tempPath = $path+"Global_Catalog.txt"
  34. echo "**** Finding Global Catalogs ****" > $tempPath
  35. Invoke-Command -ComputerName $computer -ScriptBlock { dsquery server -isgc } >> $tempPath
  36.  
  37. $tempPath = $path+"DNS_TEST.txt"
  38. echo "**** Running DCDiag DNS Test ****" > $tempPath
  39. Invoke-Command -ComputerName $computer -ScriptBlock { dcdiag /test:dns } >> $tempPath
  40.  
  41. $tempPath = $path+"DNS_Registration.txt"
  42. echo "**** Test DNS Registration ****" > $tempPath
  43. Invoke-Command -ComputerName $computer -ScriptBlock { dcdiag /test:registerindns /dnsdomain:omni.lan } >> $tempPath
  44.  
  45. $tempPath = $path+"Network_Diag.txt"
  46. echo "**** Network Connectivity Tester ****" > $tempPath
  47. Invoke-Command -ComputerName $computer -ScriptBlock { netdiag /v } >> $tempPath
  48.  
  49. $tempPath = $path+"Verify_Trust.txt"
  50. echo "**** Verify Trust Relationships ****" > $tempPath
  51. Invoke-Command -ComputerName $computer -ScriptBlock { netdom query /verify trust } >> $tempPath
  52.  
  53. $tempPath = $path+"Show_Replications.txt"
  54. echo "**** Show Replication and if it was successful or not ****" > $tempPath
  55. Invoke-Command -ComputerName $computer -ScriptBlock { repadmin /showreps } >> $tempPath
  56.  
  57. $tempPath = $path+"Replication_Errors.txt"
  58. echo "**** Replicatoin Errors check ****" > $tempPath
  59. Invoke-Command -ComputerName $computer -ScriptBlock { repadmin /replsum /errorsonly } >> $tempPath
  60.  
  61. $tempPath = $path+"DHCP_Servers.txt"
  62. echo "**** verify the DHCP server count and names ****" > $tempPath
  63. Invoke-Command -ComputerName $computer -ScriptBlock { Netsh dhcp show server } >> $tempPath
  64.  
  65. $tempPath = $path+"GPO_Status.txt"
  66. echo "**** Checking GPO Status ****" > $tempPath
  67. Invoke-Command -ComputerName $computer -ScriptBlock { gpotool /v } >> $tempPath
  68.  
  69. }
  70.  
  71.  
  72. $DCs = Get-DomainControllers("dc=omni,dc=lan")
  73.  
  74. foreach($DC in $DCs){
  75. Start-Job { Run-Report($DC) }
  76. }
Add Comment
Please, Sign In to add comment