add gpo counter variable to powershell script for visbility
This commit is contained in:
+55
-28
@@ -29,8 +29,11 @@ function getLinkedOUs(string $gpo): array|false
|
||||
//return implode("\n", $decoded);
|
||||
}
|
||||
|
||||
?>
|
||||
$yaml_timestamp = json_decode(file_get_contents('http://172.17.0.1:5000/timestamp'), true);
|
||||
$gpo_links = json_decode(file_get_contents('http://172.17.0.1:5000/gpo_links'), true);
|
||||
$index_duration = json_decode(file_get_contents('http://172.17.0.1:5000/index_duration'), true);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -42,9 +45,13 @@ function getLinkedOUs(string $gpo): array|false
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Query GPOs by Group</h2>
|
||||
This tool allows you to query Group Policy Objects in Active Directory by Restricted Group.<br>
|
||||
This tool is intended to help determine what OU to use for a specific group.<br>
|
||||
Users often request systems with a certain security group assigned.<br>
|
||||
Since AD has no way to look this up, this makes it challenging to match groups to OUs.<p>
|
||||
This site has all restricted groups indexed by GPO and OU.<br>
|
||||
Search is case insensitive and supports partial match. <br>
|
||||
Once you have the GPO name, you can locate this in the GPO management snap-in and find what OUs it links to.<br><p>
|
||||
The OUs liked to the GPOs will show up as a hover tooltip on the GPO name.<br>
|
||||
Clicking on the GPO name will list all linked OUs.<br><p>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
||||
@@ -56,8 +63,9 @@ if (isset($_GET['group'])) {
|
||||
<form action="index.php" method="GET">
|
||||
<label for="group">Group Name:</label>
|
||||
<input type="text" id="group" name="group" value="'.htmlspecialchars($_GET['group']).'" required>
|
||||
<button type="submit">Query</button>
|
||||
<button type="submit">Query</button><br>
|
||||
</form><p>
|
||||
Return <a href=/>Home</a><br>
|
||||
';
|
||||
$group = urlencode($_GET['group']);
|
||||
$url = "http://172.17.0.1:5000/gpo?group=$group";
|
||||
@@ -107,31 +115,43 @@ if (isset($_GET['group'])) {
|
||||
}
|
||||
ksort($gpoMap, SORT_STRING | SORT_FLAG_CASE);
|
||||
if($numResults > 0){
|
||||
echo 'Total results: '.$numResults.'<br>
|
||||
echo '
|
||||
Total results: '.$numResults.'<br>
|
||||
Data indexed at '.$yaml_timestamp['timestamp'].' after '.$index_duration['duration'].' minutes<br>
|
||||
Total Linked GPOs: '.$gpo_links['gpo_links'].'<p>
|
||||
<table border="1" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<th>
|
||||
GPO
|
||||
</th>
|
||||
<th>
|
||||
Administrators
|
||||
</th>
|
||||
<th>
|
||||
vnc_admin
|
||||
</th>
|
||||
</tr>
|
||||
';
|
||||
echo '<table border="1" cellpadding="4" cellspacing="0">
|
||||
';
|
||||
echo '<tr><th>GPO</th><th>Administrators</th><th>vnc_admin</th></tr>
|
||||
';
|
||||
|
||||
foreach ($gpoMap as $gpoName => $cols) {
|
||||
// Remove duplicates and build comma‑separated lists
|
||||
$adminGroups = implode('<br>', array_unique($cols['administrators']));
|
||||
$vncGroups = implode('<br>', array_unique($cols['vnc_admin']));
|
||||
$linkedOUs = implode("\n", getLinkedOUs($gpoName));
|
||||
echo ' <tr>
|
||||
';
|
||||
echo " <td>
|
||||
<div title='$linkedOUs'>
|
||||
<a href=/?gpo='$gpoName'>{$gpoName}</a>
|
||||
</div></td>
|
||||
echo "
|
||||
<tr>
|
||||
<td>
|
||||
<div title='$linkedOUs'>
|
||||
<a href=/?gpo=$gpoName>{$gpoName}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{$adminGroups}
|
||||
</td>
|
||||
<td>
|
||||
{$vncGroups}
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
echo " <td>{$adminGroups}</td>
|
||||
";
|
||||
echo " <td>{$vncGroups}</td>
|
||||
";
|
||||
echo ' </tr>
|
||||
';
|
||||
}
|
||||
echo '</table>
|
||||
';
|
||||
@@ -140,17 +160,20 @@ if (isset($_GET['group'])) {
|
||||
echo 'No results found for query <b>'.$_GET['group'].'</b>.<p>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if you click on a GPO name, print all OUs
|
||||
else if (isset($_GET['gpo'])) {
|
||||
echo 'OUs linked to GPO <b>'.$_GET['gpo'].':</b><p>';
|
||||
echo 'OUs linked to GPO <b>'.$_GET['gpo'].':</b><p><ul>';
|
||||
$LinkedOUs = getLinkedOUs($_GET['gpo']);
|
||||
echo implode("<br>", $LinkedOUs);
|
||||
echo '<br>Return <a href=/>Home</a>';
|
||||
foreach ($LinkedOUs as $OU){
|
||||
echo "<li>".$OU."</li>";
|
||||
}
|
||||
#echo implode("<li>", $LinkedOUs);
|
||||
echo '</ul><p>Return <a href=/>Home</a>';
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
echo '
|
||||
<form action="index.php" method="GET">
|
||||
@@ -158,10 +181,14 @@ else {
|
||||
<input type="text" id="group" name="group" required>
|
||||
<button type="submit">Query</button>
|
||||
</form><p>
|
||||
Data indexed at '.$yaml_timestamp['timestamp'].' after '.$index_duration['duration'].' minutes<br>
|
||||
Total Linked GPOs: '.$gpo_links['gpo_links'].'<p>
|
||||
No group specified.</p>
|
||||
';
|
||||
echo "<p>No group specified.</p>";
|
||||
|
||||
}
|
||||
echo "</div>";
|
||||
echo "</div>
|
||||
";
|
||||
//echo "<p>Source code can be found <a target='_blank' rel='noopener noreferrer' href='https://gitea.matt-cloud.com/matt/gpo_lookup'>here</a>.<p>";
|
||||
?>
|
||||
|
||||
|
||||
@@ -67,11 +67,6 @@ h1, h2, h3, h4 {
|
||||
color: #bdc3c7; /* Dimmer text color */
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-bottom: 10px;
|
||||
color: #bdc3c7; /* Dimmer text color */
|
||||
|
||||
Reference in New Issue
Block a user